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
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
RollupAdminLogic
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./IRollupAdmin.sol"; import "./IRollupLogic.sol"; import "./RollupCore.sol"; import "../bridge/IOutbox.sol"; import "../bridge/ISequencerInbox.sol"; import "../challenge/IChallengeManager.sol"; import "../libraries/DoubleLogicUUPSUpgradeable.sol"; import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; import {NO_CHAL_INDEX} from "../libraries/Constants.sol"; contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeable { function initialize(Config calldata config, ContractDependencies calldata connectedContracts) external override onlyProxy initializer { rollupDeploymentBlock = block.number; bridge = connectedContracts.bridge; sequencerInbox = connectedContracts.sequencerInbox; connectedContracts.bridge.setDelayedInbox(address(connectedContracts.inbox), true); connectedContracts.bridge.setSequencerInbox(address(connectedContracts.sequencerInbox)); inbox = connectedContracts.inbox; outbox = connectedContracts.outbox; connectedContracts.bridge.setOutbox(address(connectedContracts.outbox), true); rollupEventInbox = connectedContracts.rollupEventInbox; connectedContracts.bridge.setDelayedInbox( address(connectedContracts.rollupEventInbox), true ); connectedContracts.rollupEventInbox.rollupInitialized(config.chainId, config.chainConfig); connectedContracts.sequencerInbox.addSequencerL2Batch( 0, "", 1, IGasRefunder(address(0)), 0, 1 ); validatorUtils = connectedContracts.validatorUtils; validatorWalletCreator = connectedContracts.validatorWalletCreator; challengeManager = connectedContracts.challengeManager; Node memory node = createInitialNode(); initializeCore(node); confirmPeriodBlocks = config.confirmPeriodBlocks; extraChallengeTimeBlocks = config.extraChallengeTimeBlocks; chainId = config.chainId; baseStake = config.baseStake; wasmModuleRoot = config.wasmModuleRoot; // A little over 15 minutes minimumAssertionPeriod = 75; // the owner can't access the rollup user facet where escrow is redeemable require(config.loserStakeEscrow != _getAdmin(), "INVALID_ESCROW_ADMIN"); // this next check shouldn't be an issue if the owner controls an AdminProxy // that accesses the admin facet, but still seems like a good extra precaution require(config.loserStakeEscrow != config.owner, "INVALID_ESCROW_OWNER"); loserStakeEscrow = config.loserStakeEscrow; stakeToken = config.stakeToken; emit RollupInitialized(config.wasmModuleRoot, config.chainId); } function createInitialNode() private view returns (Node memory) { GlobalState memory emptyGlobalState; bytes32 state = RollupLib.stateHashMem( ExecutionState(emptyGlobalState, MachineStatus.FINISHED), 1 // inboxMaxCount - force the first assertion to read a message ); return NodeLib.createNode( state, 0, // challenge hash (not challengeable) 0, // confirm data 0, // prev node uint64(block.number), // deadline block (not challengeable) 0 // initial node has a node hash of 0 ); } /** * Functions are only to reach this logic contract if the caller is the owner * so there is no need for a redundant onlyOwner check */ /** * @notice Add a contract authorized to put messages into this rollup's inbox * @param _outbox Outbox contract to add */ function setOutbox(IOutbox _outbox) external override { outbox = _outbox; bridge.setOutbox(address(_outbox), true); emit OwnerFunctionCalled(0); } /** * @notice Disable an old outbox from interacting with the bridge * @param _outbox Outbox contract to remove */ function removeOldOutbox(address _outbox) external override { require(_outbox != address(outbox), "CUR_OUTBOX"); bridge.setOutbox(_outbox, false); emit OwnerFunctionCalled(1); } /** * @notice Enable or disable an inbox contract * @param _inbox Inbox contract to add or remove * @param _enabled New status of inbox */ function setDelayedInbox(address _inbox, bool _enabled) external override { bridge.setDelayedInbox(address(_inbox), _enabled); emit OwnerFunctionCalled(2); } /** * @notice Pause interaction with the rollup contract. * The time spent paused is not incremented in the rollup's timing for node validation. * @dev this function may be frontrun by a validator (ie to create a node before the system is paused). * The pause should be called atomically with required checks to be sure the system is paused in a consistent state. * The RollupAdmin may execute a check against the Rollup's latest node num or the ChallengeManager, then execute this function atomically with it. */ function pause() external override { _pause(); emit OwnerFunctionCalled(3); } /** * @notice Resume interaction with the rollup contract */ function resume() external override { _unpause(); emit OwnerFunctionCalled(4); } /// @notice allows the admin to upgrade the primary logic contract (ie rollup admin logic, aka this) /// @dev this function doesn't revert as this primary logic contract is only /// reachable by the proxy's admin function _authorizeUpgrade(address newImplementation) internal override {} /// @notice allows the admin to upgrade the secondary logic contract (ie rollup user logic) /// @dev this function doesn't revert as this primary logic contract is only /// reachable by the proxy's admin function _authorizeSecondaryUpgrade(address newImplementation) internal override {} /** * @notice Set the addresses of the validator whitelist * @dev It is expected that both arrays are same length, and validator at * position i corresponds to the value at position i * @param _validator addresses to set in the whitelist * @param _val value to set in the whitelist for corresponding address */ function setValidator(address[] calldata _validator, bool[] calldata _val) external override { require(_validator.length > 0, "EMPTY_ARRAY"); require(_validator.length == _val.length, "WRONG_LENGTH"); for (uint256 i = 0; i < _validator.length; i++) { isValidator[_validator[i]] = _val[i]; } emit OwnerFunctionCalled(6); } /** * @notice Set a new owner address for the rollup * @dev it is expected that only the rollup admin can use this facet to set a new owner * @param newOwner address of new rollup owner */ function setOwner(address newOwner) external override { _changeAdmin(newOwner); emit OwnerFunctionCalled(7); } /** * @notice Set minimum assertion period for the rollup * @param newPeriod new minimum period for assertions */ function setMinimumAssertionPeriod(uint256 newPeriod) external override { minimumAssertionPeriod = newPeriod; emit OwnerFunctionCalled(8); } /** * @notice Set number of blocks until a node is considered confirmed * @param newConfirmPeriod new number of blocks */ function setConfirmPeriodBlocks(uint64 newConfirmPeriod) external override { require(newConfirmPeriod > 0, "INVALID_CONFIRM_PERIOD"); confirmPeriodBlocks = newConfirmPeriod; emit OwnerFunctionCalled(9); } /** * @notice Set number of extra blocks after a challenge * @param newExtraTimeBlocks new number of blocks */ function setExtraChallengeTimeBlocks(uint64 newExtraTimeBlocks) external override { extraChallengeTimeBlocks = newExtraTimeBlocks; emit OwnerFunctionCalled(10); } /** * @notice Set base stake required for an assertion * @param newBaseStake minimum amount of stake required */ function setBaseStake(uint256 newBaseStake) external override { baseStake = newBaseStake; emit OwnerFunctionCalled(12); } /** * @notice Set the token used for stake, where address(0) == eth * @dev Before changing the base stake token, you might need to change the * implementation of the Rollup User facet! * @param newStakeToken address of token used for staking */ function setStakeToken(address newStakeToken) external override whenPaused { /* * To change the stake token without breaking consistency one would need to: * Pause the system, have all stakers remove their funds, * update the user logic to handle ERC20s, change the stake token, then resume. * * Note: To avoid loss of funds stakers must remove their funds and claim all the * available withdrawable funds before the system is paused. */ bool expectERC20Support = newStakeToken != address(0); // this assumes the rollup isn't its own admin. if needed, instead use a ProxyAdmin by OZ! bool actualERC20Support = IRollupUser(address(this)).isERC20Enabled(); require(actualERC20Support == expectERC20Support, "NO_USER_LOGIC_SUPPORT"); require(stakerCount() == 0, "NO_ACTIVE_STAKERS"); require(totalWithdrawableFunds == 0, "NO_PENDING_WITHDRAW"); stakeToken = newStakeToken; emit OwnerFunctionCalled(13); } /** * @notice Upgrades the implementation of a beacon controlled by the rollup * @param beacon address of beacon to be upgraded * @param newImplementation new address of implementation */ function upgradeBeacon(address beacon, address newImplementation) external override { UpgradeableBeacon(beacon).upgradeTo(newImplementation); emit OwnerFunctionCalled(20); } function forceResolveChallenge(address[] calldata stakerA, address[] calldata stakerB) external override whenPaused { require(stakerA.length > 0, "EMPTY_ARRAY"); require(stakerA.length == stakerB.length, "WRONG_LENGTH"); for (uint256 i = 0; i < stakerA.length; i++) { uint64 chall = inChallenge(stakerA[i], stakerB[i]); require(chall != NO_CHAL_INDEX, "NOT_IN_CHALL"); clearChallenge(stakerA[i]); clearChallenge(stakerB[i]); challengeManager.clearChallenge(chall); } emit OwnerFunctionCalled(21); } function forceRefundStaker(address[] calldata staker) external override whenPaused { require(staker.length > 0, "EMPTY_ARRAY"); for (uint256 i = 0; i < staker.length; i++) { require(_stakerMap[staker[i]].currentChallenge == NO_CHAL_INDEX, "STAKER_IN_CHALL"); reduceStakeTo(staker[i], 0); turnIntoZombie(staker[i]); } emit OwnerFunctionCalled(22); } function forceCreateNode( uint64 prevNode, uint256 prevNodeInboxMaxCount, Assertion calldata assertion, bytes32 expectedNodeHash ) external override whenPaused { require(prevNode == latestConfirmed(), "ONLY_LATEST_CONFIRMED"); createNewNode(assertion, prevNode, prevNodeInboxMaxCount, expectedNodeHash); emit OwnerFunctionCalled(23); } function forceConfirmNode( uint64 nodeNum, bytes32 blockHash, bytes32 sendRoot ) external override whenPaused { // this skips deadline, staker and zombie validation confirmNode(nodeNum, blockHash, sendRoot); emit OwnerFunctionCalled(24); } function setLoserStakeEscrow(address newLoserStakerEscrow) external override { // escrow holder can't be proxy admin, since escrow is only redeemable through // the primary user logic contract require(newLoserStakerEscrow != _getAdmin(), "INVALID_ESCROW"); loserStakeEscrow = newLoserStakerEscrow; emit OwnerFunctionCalled(25); } /** * @notice Set the proving WASM module root * @param newWasmModuleRoot new module root */ function setWasmModuleRoot(bytes32 newWasmModuleRoot) external override { wasmModuleRoot = newWasmModuleRoot; emit OwnerFunctionCalled(26); } /** * @notice set a new sequencer inbox contract * @param _sequencerInbox new address of sequencer inbox */ function setSequencerInbox(address _sequencerInbox) external override { bridge.setSequencerInbox(_sequencerInbox); emit OwnerFunctionCalled(27); } /** * @notice sets the rollup's inbox reference. Does not update the bridge's view. * @param newInbox new address of inbox */ function setInbox(IInboxBase newInbox) external { inbox = newInbox; emit OwnerFunctionCalled(28); } function createNitroMigrationGenesis(Assertion calldata assertion) external whenPaused { bytes32 expectedSendRoot = bytes32(0); uint64 expectedInboxCount = 1; require(latestNodeCreated() == 0, "NON_GENESIS_NODES_EXIST"); require(GlobalStateLib.isEmpty(assertion.beforeState.globalState), "NOT_EMPTY_BEFORE"); require( assertion.beforeState.machineStatus == MachineStatus.FINISHED, "BEFORE_MACHINE_NOT_FINISHED" ); // accessors such as state.getSendRoot not available for calldata structs, only memory require( assertion.afterState.globalState.bytes32Vals[1] == expectedSendRoot, "NOT_ZERO_SENDROOT" ); require( assertion.afterState.globalState.u64Vals[0] == expectedInboxCount, "INBOX_NOT_AT_ONE" ); require(assertion.afterState.globalState.u64Vals[1] == 0, "POSITION_IN_MESSAGE_NOT_ZERO"); require( assertion.afterState.machineStatus == MachineStatus.FINISHED, "AFTER_MACHINE_NOT_FINISHED" ); bytes32 genesisBlockHash = assertion.afterState.globalState.bytes32Vals[0]; createNewNode(assertion, 0, expectedInboxCount, bytes32(0)); confirmNode(1, genesisBlockHash, expectedSendRoot); emit OwnerFunctionCalled(29); } /** * @notice set the validatorWhitelistDisabled flag * @param _validatorWhitelistDisabled new value of validatorWhitelistDisabled, i.e. true = disabled */ function setValidatorWhitelistDisabled(bool _validatorWhitelistDisabled) external { validatorWhitelistDisabled = _validatorWhitelistDisabled; emit OwnerFunctionCalled(30); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; 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. * * 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 initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { 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.5.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 * ==== * * [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 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 // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) 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() { _transferOwnership(_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 { _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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol) pragma solidity ^0.8.0; import "./IBeacon.sol"; import "../../access/Ownable.sol"; import "../../utils/Address.sol"; /** * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their * implementation contract, which is where they will delegate all function calls. * * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon. */ contract UpgradeableBeacon is IBeacon, Ownable { address private _implementation; /** * @dev Emitted when the implementation returned by the beacon is changed. */ event Upgraded(address indexed implementation); /** * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the * beacon. */ constructor(address implementation_) { _setImplementation(implementation_); } /** * @dev Returns the current implementation address. */ function implementation() public view virtual override returns (address) { return _implementation; } /** * @dev Upgrades the beacon to a new implementation. * * Emits an {Upgraded} event. * * Requirements: * * - msg.sender must be the owner of the contract. * - `newImplementation` must be a contract. */ function upgradeTo(address newImplementation) public virtual onlyOwner { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation contract address for this beacon * * Requirements: * * - `newImplementation` must be a contract. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract"); _implementation = newImplementation; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate that the this implementation remains valid after an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @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 * ==== * * [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 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; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; import "./IOwnable.sol"; interface IBridge { event MessageDelivered( uint256 indexed messageIndex, bytes32 indexed beforeInboxAcc, address inbox, uint8 kind, address sender, bytes32 messageDataHash, uint256 baseFeeL1, uint64 timestamp ); event BridgeCallTriggered( address indexed outbox, address indexed to, uint256 value, bytes data ); event InboxToggle(address indexed inbox, bool enabled); event OutboxToggle(address indexed outbox, bool enabled); event SequencerInboxUpdated(address newSequencerInbox); event RollupUpdated(address rollup); function allowedDelayedInboxList(uint256) external returns (address); function allowedOutboxList(uint256) external returns (address); /// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message. function delayedInboxAccs(uint256) external view returns (bytes32); /// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message. function sequencerInboxAccs(uint256) external view returns (bytes32); function rollup() external view returns (IOwnable); function sequencerInbox() external view returns (address); function activeOutbox() external view returns (address); function allowedDelayedInboxes(address inbox) external view returns (bool); function allowedOutboxes(address outbox) external view returns (bool); function sequencerReportedSubMessageCount() external view returns (uint256); function executeCall( address to, uint256 value, bytes calldata data ) external returns (bool success, bytes memory returnData); function delayedMessageCount() external view returns (uint256); function sequencerMessageCount() external view returns (uint256); // ---------- onlySequencerInbox functions ---------- function enqueueSequencerMessage( bytes32 dataHash, uint256 afterDelayedMessagesRead, uint256 prevMessageCount, uint256 newMessageCount ) external returns ( uint256 seqMessageIndex, bytes32 beforeAcc, bytes32 delayedAcc, bytes32 acc ); /** * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type * This is done through a separate function entrypoint instead of allowing the sequencer inbox * to call `enqueueDelayedMessage` to avoid the gas overhead of an extra SLOAD in either * every delayed inbox or every sequencer inbox call. */ function submitBatchSpendingReport(address batchPoster, bytes32 dataHash) external returns (uint256 msgNum); // ---------- onlyRollupOrOwner functions ---------- function setSequencerInbox(address _sequencerInbox) external; function setDelayedInbox(address inbox, bool enabled) external; function setOutbox(address inbox, bool enabled) external; function updateRollupAddress(IOwnable _rollup) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; interface IDelayedMessageProvider { /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator event InboxMessageDelivered(uint256 indexed messageNum, bytes data); /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator /// same as InboxMessageDelivered but the batch data is available in tx.input event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; import "./IBridge.sol"; import "./IDelayedMessageProvider.sol"; import "./ISequencerInbox.sol"; interface IInboxBase is IDelayedMessageProvider { function bridge() external view returns (IBridge); function sequencerInbox() external view returns (ISequencerInbox); function maxDataSize() external view returns (uint256); /** * @notice Send a generic L2 message to the chain * @dev This method is an optimization to avoid having to emit the entirety of the messageData in a log. Instead validators are expected to be able to parse the data from the transaction's input * @param messageData Data of the message being sent */ function sendL2MessageFromOrigin(bytes calldata messageData) external returns (uint256); /** * @notice Send a generic L2 message to the chain * @dev This method can be used to send any type of message that doesn't require L1 validation * @param messageData Data of the message being sent */ function sendL2Message(bytes calldata messageData) external returns (uint256); function sendUnsignedTransaction( uint256 gasLimit, uint256 maxFeePerGas, uint256 nonce, address to, uint256 value, bytes calldata data ) external returns (uint256); function sendContractTransaction( uint256 gasLimit, uint256 maxFeePerGas, address to, uint256 value, bytes calldata data ) external returns (uint256); /** * @notice Get the L1 fee for submitting a retryable * @dev This fee can be paid by funds already in the L2 aliased address or by the current message value * @dev This formula may change in the future, to future proof your code query this method instead of inlining!! * @param dataLength The length of the retryable's calldata, in bytes * @param baseFee The block basefee when the retryable is included in the chain, if 0 current block.basefee will be used */ function calculateRetryableSubmissionFee(uint256 dataLength, uint256 baseFee) external view returns (uint256); // ---------- onlyRollupOrOwner functions ---------- /// @notice pauses all inbox functionality function pause() external; /// @notice unpauses all inbox functionality function unpause() external; /// @notice add or remove users from allowList function setAllowList(address[] memory user, bool[] memory val) external; /// @notice enable or disable allowList function setAllowListEnabled(bool _allowListEnabled) external; /// @notice check if user is in allowList function isAllowed(address user) external view returns (bool); /// @notice check if allowList is enabled function allowListEnabled() external view returns (bool); function initialize(IBridge _bridge, ISequencerInbox _sequencerInbox) external; /// @notice returns the current admin function getProxyAdmin() external view returns (address); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; import "./IBridge.sol"; interface IOutbox { event SendRootUpdated(bytes32 indexed outputRoot, bytes32 indexed l2BlockHash); event OutBoxTransactionExecuted( address indexed to, address indexed l2Sender, uint256 indexed zero, uint256 transactionIndex ); function initialize(IBridge _bridge) external; function rollup() external view returns (address); // the rollup contract function bridge() external view returns (IBridge); // the bridge contract function spent(uint256) external view returns (bytes32); // packed spent bitmap function roots(bytes32) external view returns (bytes32); // maps root hashes => L2 block hash // solhint-disable-next-line func-name-mixedcase function OUTBOX_VERSION() external view returns (uint128); // the outbox version function updateSendRoot(bytes32 sendRoot, bytes32 l2BlockHash) external; function updateRollupAddress() external; /// @notice When l2ToL1Sender returns a nonzero address, the message was originated by an L2 account /// When the return value is zero, that means this is a system message /// @dev the l2ToL1Sender behaves as the tx.origin, the msg.sender should be validated to protect against reentrancies function l2ToL1Sender() external view returns (address); /// @return l2Block return L2 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active function l2ToL1Block() external view returns (uint256); /// @return l1Block return L1 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active function l2ToL1EthBlock() external view returns (uint256); /// @return timestamp return L2 timestamp when the L2 tx was initiated or 0 if no L2 to L1 transaction is active function l2ToL1Timestamp() external view returns (uint256); /// @return outputId returns the unique output identifier of the L2 to L1 tx or 0 if no L2 to L1 transaction is active function l2ToL1OutputId() external view returns (bytes32); /** * @notice Executes a messages in an Outbox entry. * @dev Reverts if dispute period hasn't expired, since the outbox entry * is only created once the rollup confirms the respective assertion. * @dev it is not possible to execute any L2-to-L1 transaction which contains data * to a contract address without any code (as enforced by the Bridge contract). * @param proof Merkle proof of message inclusion in send root * @param index Merkle path to message * @param l2Sender sender if original message (i.e., caller of ArbSys.sendTxToL1) * @param to destination address for L1 contract call * @param l2Block l2 block number at which sendTxToL1 call was made * @param l1Block l1 block number at which sendTxToL1 call was made * @param l2Timestamp l2 Timestamp at which sendTxToL1 call was made * @param value wei in L1 message * @param data abi-encoded L1 message data */ function executeTransaction( bytes32[] calldata proof, uint256 index, address l2Sender, address to, uint256 l2Block, uint256 l1Block, uint256 l2Timestamp, uint256 value, bytes calldata data ) external; /** * @dev function used to simulate the result of a particular function call from the outbox * it is useful for things such as gas estimates. This function includes all costs except for * proof validation (which can be considered offchain as a somewhat of a fixed cost - it's * not really a fixed cost, but can be treated as so with a fixed overhead for gas estimation). * We can't include the cost of proof validation since this is intended to be used to simulate txs * that are included in yet-to-be confirmed merkle roots. The simulation entrypoint could instead pretend * to confirm a pending merkle root, but that would be less practical for integrating with tooling. * It is only possible to trigger it when the msg sender is address zero, which should be impossible * unless under simulation in an eth_call or eth_estimateGas */ function executeTransactionSimulation( uint256 index, address l2Sender, address to, uint256 l2Block, uint256 l1Block, uint256 l2Timestamp, uint256 value, bytes calldata data ) external; /** * @param index Merkle path to message * @return true if the message has been spent */ function isSpent(uint256 index) external view returns (bool); function calculateItemHash( address l2Sender, address to, uint256 l2Block, uint256 l1Block, uint256 l2Timestamp, uint256 value, bytes calldata data ) external pure returns (bytes32); function calculateMerkleRoot( bytes32[] memory proof, uint256 path, bytes32 item ) external pure returns (bytes32); /** * @dev function to be called one time during the outbox upgrade process * this is used to fix the storage slots */ function postUpgradeInit() external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.4.21 <0.9.0; interface IOwnable { function owner() external view returns (address); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; pragma experimental ABIEncoderV2; import "../libraries/IGasRefunder.sol"; import "./IDelayedMessageProvider.sol"; import "./IBridge.sol"; interface ISequencerInbox is IDelayedMessageProvider { struct MaxTimeVariation { uint256 delayBlocks; uint256 futureBlocks; uint256 delaySeconds; uint256 futureSeconds; } struct TimeBounds { uint64 minTimestamp; uint64 maxTimestamp; uint64 minBlockNumber; uint64 maxBlockNumber; } enum BatchDataLocation { TxInput, SeparateBatchEvent, NoData } event SequencerBatchDelivered( uint256 indexed batchSequenceNumber, bytes32 indexed beforeAcc, bytes32 indexed afterAcc, bytes32 delayedAcc, uint256 afterDelayedMessagesRead, TimeBounds timeBounds, BatchDataLocation dataLocation ); event OwnerFunctionCalled(uint256 indexed id); /// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input event SequencerBatchData(uint256 indexed batchSequenceNumber, bytes data); /// @dev a valid keyset was added event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes); /// @dev a keyset was invalidated event InvalidateKeyset(bytes32 indexed keysetHash); function totalDelayedMessagesRead() external view returns (uint256); function bridge() external view returns (IBridge); /// @dev The size of the batch header // solhint-disable-next-line func-name-mixedcase function HEADER_LENGTH() external view returns (uint256); /// @dev If the first batch data byte after the header has this bit set, /// the sequencer inbox has authenticated the data. Currently not used. // solhint-disable-next-line func-name-mixedcase function DATA_AUTHENTICATED_FLAG() external view returns (bytes1); function rollup() external view returns (IOwnable); function isBatchPoster(address) external view returns (bool); function isSequencer(address) external view returns (bool); function maxDataSize() external view returns (uint256); struct DasKeySetInfo { bool isValidKeyset; uint64 creationBlock; } function maxTimeVariation() external view returns ( uint256, uint256, uint256, uint256 ); function dasKeySetInfo(bytes32) external view returns (bool, uint64); /// @notice Remove force inclusion delay after a L1 chainId fork function removeDelayAfterFork() external; /// @notice Force messages from the delayed inbox to be included in the chain /// Callable by any address, but message can only be force-included after maxTimeVariation.delayBlocks and /// maxTimeVariation.delaySeconds has elapsed. As part of normal behaviour the sequencer will include these /// messages so it's only necessary to call this if the sequencer is down, or not including any delayed messages. /// @param _totalDelayedMessagesRead The total number of messages to read up to /// @param kind The kind of the last message to be included /// @param l1BlockAndTime The l1 block and the l1 timestamp of the last message to be included /// @param baseFeeL1 The l1 gas price of the last message to be included /// @param sender The sender of the last message to be included /// @param messageDataHash The messageDataHash of the last message to be included function forceInclusion( uint256 _totalDelayedMessagesRead, uint8 kind, uint64[2] calldata l1BlockAndTime, uint256 baseFeeL1, address sender, bytes32 messageDataHash ) external; function inboxAccs(uint256 index) external view returns (bytes32); function batchCount() external view returns (uint256); function isValidKeysetHash(bytes32 ksHash) external view returns (bool); /// @notice the creation block is intended to still be available after a keyset is deleted function getKeysetCreationBlock(bytes32 ksHash) external view returns (uint256); // ---------- BatchPoster functions ---------- function addSequencerL2BatchFromOrigin( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder ) external; function addSequencerL2Batch( uint256 sequenceNumber, bytes calldata data, uint256 afterDelayedMessagesRead, IGasRefunder gasRefunder, uint256 prevMessageCount, uint256 newMessageCount ) external; // ---------- onlyRollupOrOwner functions ---------- /** * @notice Set max delay for sequencer inbox * @param maxTimeVariation_ the maximum time variation parameters */ function setMaxTimeVariation(MaxTimeVariation memory maxTimeVariation_) external; /** * @notice Updates whether an address is authorized to be a batch poster at the sequencer inbox * @param addr the address * @param isBatchPoster_ if the specified address should be authorized as a batch poster */ function setIsBatchPoster(address addr, bool isBatchPoster_) external; /** * @notice Makes Data Availability Service keyset valid * @param keysetBytes bytes of the serialized keyset */ function setValidKeyset(bytes calldata keysetBytes) external; /** * @notice Invalidates a Data Availability Service keyset * @param ksHash hash of the keyset */ function invalidateKeysetHash(bytes32 ksHash) external; /** * @notice Updates whether an address is authorized to be a sequencer. * @dev The IsSequencer information is used only off-chain by the nitro node to validate sequencer feed signer. * @param addr the address * @param isSequencer_ if the specified address should be authorized as a sequencer */ function setIsSequencer(address addr, bool isSequencer_) external; // ---------- initializer ---------- function initialize(IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_) external; function updateRollupAddress() external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../state/Machine.sol"; import "../state/GlobalState.sol"; library ChallengeLib { using MachineLib for Machine; using ChallengeLib for Challenge; /// @dev It's assumed that that uninitialzed challenges have mode NONE enum ChallengeMode { NONE, BLOCK, EXECUTION } struct Participant { address addr; uint256 timeLeft; } struct Challenge { Participant current; Participant next; uint256 lastMoveTimestamp; bytes32 wasmModuleRoot; bytes32 challengeStateHash; uint64 maxInboxMessages; ChallengeMode mode; } struct SegmentSelection { uint256 oldSegmentsStart; uint256 oldSegmentsLength; bytes32[] oldSegments; uint256 challengePosition; } function timeUsedSinceLastMove(Challenge storage challenge) internal view returns (uint256) { return block.timestamp - challenge.lastMoveTimestamp; } function isTimedOut(Challenge storage challenge) internal view returns (bool) { return challenge.timeUsedSinceLastMove() > challenge.current.timeLeft; } function getStartMachineHash(bytes32 globalStateHash, bytes32 wasmModuleRoot) internal pure returns (bytes32) { // Start the value stack with the function call ABI for the entrypoint Value[] memory startingValues = new Value[](3); startingValues[0] = ValueLib.newRefNull(); startingValues[1] = ValueLib.newI32(0); startingValues[2] = ValueLib.newI32(0); ValueArray memory valuesArray = ValueArray({inner: startingValues}); ValueStack memory values = ValueStack({proved: valuesArray, remainingHash: 0}); ValueStack memory internalStack; StackFrameWindow memory frameStack; Machine memory mach = Machine({ status: MachineStatus.RUNNING, valueStack: values, internalStack: internalStack, frameStack: frameStack, globalStateHash: globalStateHash, moduleIdx: 0, functionIdx: 0, functionPc: 0, modulesRoot: wasmModuleRoot }); return mach.hash(); } function getEndMachineHash(MachineStatus status, bytes32 globalStateHash) internal pure returns (bytes32) { if (status == MachineStatus.FINISHED) { return keccak256(abi.encodePacked("Machine finished:", globalStateHash)); } else if (status == MachineStatus.ERRORED) { return keccak256(abi.encodePacked("Machine errored:")); } else if (status == MachineStatus.TOO_FAR) { return keccak256(abi.encodePacked("Machine too far:")); } else { revert("BAD_BLOCK_STATUS"); } } function extractChallengeSegment(SegmentSelection calldata selection) internal pure returns (uint256 segmentStart, uint256 segmentLength) { uint256 oldChallengeDegree = selection.oldSegments.length - 1; segmentLength = selection.oldSegmentsLength / oldChallengeDegree; // Intentionally done before challengeLength is potentially added to for the final segment segmentStart = selection.oldSegmentsStart + segmentLength * selection.challengePosition; if (selection.challengePosition == selection.oldSegments.length - 2) { segmentLength += selection.oldSegmentsLength % oldChallengeDegree; } } function hashChallengeState( uint256 segmentsStart, uint256 segmentsLength, bytes32[] memory segments ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(segmentsStart, segmentsLength, segments)); } function blockStateHash(MachineStatus status, bytes32 globalStateHash) internal pure returns (bytes32) { if (status == MachineStatus.FINISHED) { return keccak256(abi.encodePacked("Block state:", globalStateHash)); } else if (status == MachineStatus.ERRORED) { return keccak256(abi.encodePacked("Block state, errored:", globalStateHash)); } else if (status == MachineStatus.TOO_FAR) { return keccak256(abi.encodePacked("Block state, too far:")); } else { revert("BAD_BLOCK_STATUS"); } } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../state/Machine.sol"; import "../bridge/IBridge.sol"; import "../bridge/ISequencerInbox.sol"; import "../osp/IOneStepProofEntry.sol"; import "./IChallengeResultReceiver.sol"; import "./ChallengeLib.sol"; interface IChallengeManager { enum ChallengeTerminationType { TIMEOUT, BLOCK_PROOF, EXECUTION_PROOF, CLEARED } event InitiatedChallenge( uint64 indexed challengeIndex, GlobalState startState, GlobalState endState ); event Bisected( uint64 indexed challengeIndex, bytes32 indexed challengeRoot, uint256 challengedSegmentStart, uint256 challengedSegmentLength, bytes32[] chainHashes ); event ExecutionChallengeBegun(uint64 indexed challengeIndex, uint256 blockSteps); event OneStepProofCompleted(uint64 indexed challengeIndex); event ChallengeEnded(uint64 indexed challengeIndex, ChallengeTerminationType kind); function initialize( IChallengeResultReceiver resultReceiver_, ISequencerInbox sequencerInbox_, IBridge bridge_, IOneStepProofEntry osp_ ) external; function createChallenge( bytes32 wasmModuleRoot_, MachineStatus[2] calldata startAndEndMachineStatuses_, GlobalState[2] calldata startAndEndGlobalStates_, uint64 numBlocks, address asserter_, address challenger_, uint256 asserterTimeLeft_, uint256 challengerTimeLeft_ ) external returns (uint64); function challengeInfo(uint64 challengeIndex_) external view returns (ChallengeLib.Challenge memory); function currentResponder(uint64 challengeIndex) external view returns (address); function isTimedOut(uint64 challengeIndex) external view returns (bool); function clearChallenge(uint64 challengeIndex_) external; function timeout(uint64 challengeIndex_) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; interface IChallengeResultReceiver { function completeChallenge( uint256 challengeIndex, address winner, address loser ) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; /// @notice An extension to OZ's ERC1967Upgrade implementation to support two logic contracts abstract contract DoubleLogicERC1967Upgrade is ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.implementation.secondary" subtracted by 1 bytes32 internal constant _IMPLEMENTATION_SECONDARY_SLOT = 0x2b1dbce74324248c222f0ec2d5ed7bd323cfc425b336f0253c5ccfda7265546d; // This is the keccak-256 hash of "eip1967.proxy.rollback.secondary" subtracted by 1 bytes32 private constant _ROLLBACK_SECONDARY_SLOT = 0x49bd798cd84788856140a4cd5030756b4d08a9e4d55db725ec195f232d262a89; /** * @dev Emitted when the secondary implementation is upgraded. */ event UpgradedSecondary(address indexed implementation); /** * @dev Returns the current secondary implementation address. */ function _getSecondaryImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SECONDARY_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setSecondaryImplementation(address newImplementation) private { require( Address.isContract(newImplementation), "ERC1967: new secondary implementation is not a contract" ); StorageSlot.getAddressSlot(_IMPLEMENTATION_SECONDARY_SLOT).value = newImplementation; } /** * @dev Perform secondary implementation upgrade * * Emits an {UpgradedSecondary} event. */ function _upgradeSecondaryTo(address newImplementation) internal { _setSecondaryImplementation(newImplementation); emit UpgradedSecondary(newImplementation); } /** * @dev Perform secondary implementation upgrade with additional setup call. * * Emits an {UpgradedSecondary} event. */ function _upgradeSecondaryToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeSecondaryTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform secondary implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {UpgradedSecondary} event. */ function _upgradeSecondaryToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SECONDARY_SLOT).value) { _setSecondaryImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require( slot == _IMPLEMENTATION_SECONDARY_SLOT, "ERC1967Upgrade: unsupported secondary proxiableUUID" ); } catch { revert("ERC1967Upgrade: new secondary implementation is not UUPS"); } _upgradeSecondaryToAndCall(newImplementation, data, forceCall); } } } /// @notice similar to TransparentUpgradeableProxy but allows the admin to fallback to a separate logic contract using DoubleLogicERC1967Upgrade /// @dev this follows the UUPS pattern for upgradeability - read more at https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v4.5.0/contracts/proxy#transparent-vs-uups-proxies contract AdminFallbackProxy is Proxy, DoubleLogicERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `adminLogic` and a secondary * logic implementation specified by `userLogic` * * Only the `adminAddr` is able to use the `adminLogic` functions * All other addresses can interact with the `userLogic` functions */ function _initialize( address adminLogic, bytes memory adminData, address userLogic, bytes memory userData, address adminAddr ) internal { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); assert( _IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) ); assert( _IMPLEMENTATION_SECONDARY_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation.secondary")) - 1) ); _changeAdmin(adminAddr); _upgradeToAndCall(adminLogic, adminData, false); _upgradeSecondaryToAndCall(userLogic, userData, false); } /// @inheritdoc Proxy function _implementation() internal view override returns (address) { require(msg.data.length >= 4, "NO_FUNC_SIG"); // if the sender is the proxy's admin, delegate to admin logic // if the admin is disabled, all calls will be forwarded to user logic // admin affordances can be disabled by setting to a no-op smart contract // since there is a check for contract code before updating the value address target = _getAdmin() != msg.sender ? DoubleLogicERC1967Upgrade._getSecondaryImplementation() : ERC1967Upgrade._getImplementation(); // implementation setters do an existence check, but we protect against selfdestructs this way require(Address.isContract(target), "TARGET_NOT_CONTRACT"); return target; } /** * @dev unlike transparent upgradeable proxies, this does allow the admin to fallback to a logic contract * the admin is expected to interact only with the primary logic contract, which handles contract * upgrades using the UUPS approach */ function _beforeFallback() internal override { super._beforeFallback(); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../precompiles/ArbSys.sol"; library ArbitrumChecker { function runningOnArbitrum() internal view returns (bool) { (bool ok, bytes memory data) = address(100).staticcall( abi.encodeWithSelector(ArbSys.arbOSVersion.selector) ); return ok && data.length == 32; } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; uint64 constant NO_CHAL_INDEX = 0; // Expected seconds per block in Ethereum PoS uint256 constant ETH_POS_BLOCK_TIME = 12;
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import {DoubleLogicERC1967Upgrade} from "./AdminFallbackProxy.sol"; import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; /// @notice An extension to OZ's UUPSUpgradeable contract to be used for handling UUPS upgrades with a DoubleLogicERC1967Upgrade proxy /// The should be used in the primary implementation slot of the DoubleLogicUUPS proxy /// @dev upgrades should be handles by the primary logic contract in order to pass the `onlyProxy` check abstract contract DoubleLogicUUPSUpgradeable is UUPSUpgradeable, DoubleLogicERC1967Upgrade { /// @inheritdoc UUPSUpgradeable function proxiableUUID() external view override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the secondary contract. Called by * {upgradeSecondaryTo} and {upgradeSecondaryToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeSecondaryUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeSecondaryUpgrade(address newImplementation) internal virtual; /** * @dev Upgrade the secondary implementation of the proxy to `newImplementation`. * * Calls {_authorizeSecondaryUpgrade}. * * Emits an {UpgradedSecondary} event. */ function upgradeSecondaryTo(address newImplementation) external onlyProxy { _authorizeSecondaryUpgrade(newImplementation); _upgradeSecondaryToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the secondary implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeSecondaryUpgrade}. * * Emits an {UpgradedSecondary} event. */ function upgradeSecondaryToAndCall(address newImplementation, bytes memory data) external payable onlyProxy { _authorizeSecondaryUpgrade(newImplementation); _upgradeSecondaryToAndCallUUPS(newImplementation, data, true); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 // solhint-disable-next-line compiler-version pragma solidity >=0.6.9 <0.9.0; interface IGasRefunder { function onGasSpent( address payable spender, uint256 gasUsed, uint256 calldataSize ) external returns (bool success); } abstract contract GasRefundEnabled { /// @dev this refunds the sender for execution costs of the tx /// calldata costs are only refunded if `msg.sender == tx.origin` to guarantee the value refunded relates to charging /// for the `tx.input`. this avoids a possible attack where you generate large calldata from a contract and get over-refunded modifier refundsGas(IGasRefunder gasRefunder) { uint256 startGasLeft = gasleft(); _; if (address(gasRefunder) != address(0)) { uint256 calldataSize = msg.data.length; uint256 calldataWords = (calldataSize + 31) / 32; // account for the CALLDATACOPY cost of the proxy contract, including the memory expansion cost startGasLeft += calldataWords * 6 + (calldataWords**2) / 512; // if triggered in a contract call, the spender may be overrefunded by appending dummy data to the call // so we check if it is a top level call, which would mean the sender paid calldata as part of tx.input // solhint-disable-next-line avoid-tx-origin if (msg.sender != tx.origin) { // We can't be sure if this calldata came from the top level tx, // so to be safe we tell the gas refunder there was no calldata. calldataSize = 0; } gasRefunder.onGasSpent(payable(msg.sender), startGasLeft - gasleft(), calldataSize); } } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./IOneStepProver.sol"; library OneStepProofEntryLib { uint256 internal constant MAX_STEPS = 1 << 43; } interface IOneStepProofEntry { function proveOneStep( ExecutionContext calldata execCtx, uint256 machineStep, bytes32 beforeHash, bytes calldata proof ) external view returns (bytes32 afterHash); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../state/Machine.sol"; import "../state/Module.sol"; import "../state/Instructions.sol"; import "../state/GlobalState.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IBridge.sol"; struct ExecutionContext { uint256 maxInboxMessagesRead; IBridge bridge; } abstract contract IOneStepProver { function executeOneStep( ExecutionContext memory execCtx, Machine calldata mach, Module calldata mod, Instruction calldata instruction, bytes calldata proof ) external view virtual returns (Machine memory result, Module memory resultMod); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.4.21 <0.9.0; /** * @title System level functionality * @notice For use by contracts to interact with core L2-specific functionality. * Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064. */ interface ArbSys { /** * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0) * @return block number as int */ function arbBlockNumber() external view returns (uint256); /** * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum) * @return block hash */ function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32); /** * @notice Gets the rollup's unique chain identifier * @return Chain identifier as int */ function arbChainID() external view returns (uint256); /** * @notice Get internal version number identifying an ArbOS build * @return version number as int */ function arbOSVersion() external view returns (uint256); /** * @notice Returns 0 since Nitro has no concept of storage gas * @return uint 0 */ function getStorageGasAvailable() external view returns (uint256); /** * @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract) * @dev this call has been deprecated and may be removed in a future release * @return true if current execution frame is not a call by another L2 contract */ function isTopLevelCall() external view returns (bool); /** * @notice map L1 sender contract address to its L2 alias * @param sender sender address * @param unused argument no longer used * @return aliased sender address */ function mapL1SenderContractAddressToL2Alias(address sender, address unused) external pure returns (address); /** * @notice check if the caller (of this caller of this) is an aliased L1 contract address * @return true iff the caller's address is an alias for an L1 contract address */ function wasMyCallersAddressAliased() external view returns (bool); /** * @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing * @return address of the caller's caller, without applying L1 contract address aliasing */ function myCallersAddressWithoutAliasing() external view returns (address); /** * @notice Send given amount of Eth to dest from sender. * This is a convenience function, which is equivalent to calling sendTxToL1 with empty data. * @param destination recipient address on L1 * @return unique identifier for this L2-to-L1 transaction. */ function withdrawEth(address destination) external payable returns (uint256); /** * @notice Send a transaction to L1 * @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data * to a contract address without any code (as enforced by the Bridge contract). * @param destination recipient address on L1 * @param data (optional) calldata for L1 contract call * @return a unique identifier for this L2-to-L1 transaction. */ function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256); /** * @notice Get send Merkle tree state * @return size number of sends in the history * @return root root hash of the send history * @return partials hashes of partial subtrees in the send history tree */ function sendMerkleTreeState() external view returns ( uint256 size, bytes32 root, bytes32[] memory partials ); /** * @notice creates a send txn from L2 to L1 * @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf */ event L2ToL1Tx( address caller, address indexed destination, uint256 indexed hash, uint256 indexed position, uint256 arbBlockNum, uint256 ethBlockNum, uint256 timestamp, uint256 callvalue, bytes data ); /// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade event L2ToL1Transaction( address caller, address indexed destination, uint256 indexed uniqueId, uint256 indexed batchNumber, uint256 indexInBatch, uint256 arbBlockNum, uint256 ethBlockNum, uint256 timestamp, uint256 callvalue, bytes data ); /** * @notice logs a merkle branch for proof synthesis * @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event * @param hash the merkle hash * @param position = (level << 192) + leaf */ event SendMerkleUpdate( uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position ); error InvalidBlockNumber(uint256 requested, uint256 current); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../state/GlobalState.sol"; import "../state/Machine.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IBridge.sol"; import "../bridge/IOutbox.sol"; import "../bridge/IInboxBase.sol"; import "./IRollupEventInbox.sol"; import "./IRollupLogic.sol"; import "../challenge/IChallengeManager.sol"; struct Config { uint64 confirmPeriodBlocks; uint64 extraChallengeTimeBlocks; address stakeToken; uint256 baseStake; bytes32 wasmModuleRoot; address owner; address loserStakeEscrow; uint256 chainId; string chainConfig; uint64 genesisBlockNum; ISequencerInbox.MaxTimeVariation sequencerInboxMaxTimeVariation; } struct ContractDependencies { IBridge bridge; ISequencerInbox sequencerInbox; IInboxBase inbox; IOutbox outbox; IRollupEventInbox rollupEventInbox; IChallengeManager challengeManager; address rollupAdminLogic; IRollupUser rollupUserLogic; // misc contracts that are useful when interacting with the rollup address validatorUtils; address validatorWalletCreator; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./IRollupCore.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IOutbox.sol"; import "../bridge/IOwnable.sol"; import "./Config.sol"; interface IRollupAdmin { event OwnerFunctionCalled(uint256 indexed id); function initialize(Config calldata config, ContractDependencies calldata connectedContracts) external; /** * @notice Add a contract authorized to put messages into this rollup's inbox * @param _outbox Outbox contract to add */ function setOutbox(IOutbox _outbox) external; /** * @notice Disable an old outbox from interacting with the bridge * @param _outbox Outbox contract to remove */ function removeOldOutbox(address _outbox) external; /** * @notice Enable or disable an inbox contract * @param _inbox Inbox contract to add or remove * @param _enabled New status of inbox */ function setDelayedInbox(address _inbox, bool _enabled) external; /** * @notice Pause interaction with the rollup contract */ function pause() external; /** * @notice Resume interaction with the rollup contract */ function resume() external; /** * @notice Set the addresses of the validator whitelist * @dev It is expected that both arrays are same length, and validator at * position i corresponds to the value at position i * @param _validator addresses to set in the whitelist * @param _val value to set in the whitelist for corresponding address */ function setValidator(address[] memory _validator, bool[] memory _val) external; /** * @notice Set a new owner address for the rollup proxy * @param newOwner address of new rollup owner */ function setOwner(address newOwner) external; /** * @notice Set minimum assertion period for the rollup * @param newPeriod new minimum period for assertions */ function setMinimumAssertionPeriod(uint256 newPeriod) external; /** * @notice Set number of blocks until a node is considered confirmed * @param newConfirmPeriod new number of blocks until a node is confirmed */ function setConfirmPeriodBlocks(uint64 newConfirmPeriod) external; /** * @notice Set number of extra blocks after a challenge * @param newExtraTimeBlocks new number of blocks */ function setExtraChallengeTimeBlocks(uint64 newExtraTimeBlocks) external; /** * @notice Set base stake required for an assertion * @param newBaseStake maximum avmgas to be used per block */ function setBaseStake(uint256 newBaseStake) external; /** * @notice Set the token used for stake, where address(0) == eth * @dev Before changing the base stake token, you might need to change the * implementation of the Rollup User logic! * @param newStakeToken address of token used for staking */ function setStakeToken(address newStakeToken) external; /** * @notice Upgrades the implementation of a beacon controlled by the rollup * @param beacon address of beacon to be upgraded * @param newImplementation new address of implementation */ function upgradeBeacon(address beacon, address newImplementation) external; function forceResolveChallenge(address[] memory stackerA, address[] memory stackerB) external; function forceRefundStaker(address[] memory stacker) external; function forceCreateNode( uint64 prevNode, uint256 prevNodeInboxMaxCount, Assertion memory assertion, bytes32 expectedNodeHash ) external; function forceConfirmNode( uint64 nodeNum, bytes32 blockHash, bytes32 sendRoot ) external; function setLoserStakeEscrow(address newLoserStakerEscrow) external; /** * @notice Set the proving WASM module root * @param newWasmModuleRoot new module root */ function setWasmModuleRoot(bytes32 newWasmModuleRoot) external; /** * @notice set a new sequencer inbox contract * @param _sequencerInbox new address of sequencer inbox */ function setSequencerInbox(address _sequencerInbox) external; /** * @notice set the validatorWhitelistDisabled flag * @param _validatorWhitelistDisabled new value of validatorWhitelistDisabled, i.e. true = disabled */ function setValidatorWhitelistDisabled(bool _validatorWhitelistDisabled) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./Node.sol"; import "../bridge/IBridge.sol"; import "../bridge/IOutbox.sol"; import "../bridge/IInboxBase.sol"; import "./IRollupEventInbox.sol"; import "../challenge/IChallengeManager.sol"; interface IRollupCore { struct Staker { uint256 amountStaked; uint64 index; uint64 latestStakedNode; // currentChallenge is 0 if staker is not in a challenge uint64 currentChallenge; bool isStaked; } event RollupInitialized(bytes32 machineHash, uint256 chainId); event NodeCreated( uint64 indexed nodeNum, bytes32 indexed parentNodeHash, bytes32 indexed nodeHash, bytes32 executionHash, Assertion assertion, bytes32 afterInboxBatchAcc, bytes32 wasmModuleRoot, uint256 inboxMaxCount ); event NodeConfirmed(uint64 indexed nodeNum, bytes32 blockHash, bytes32 sendRoot); event NodeRejected(uint64 indexed nodeNum); event RollupChallengeStarted( uint64 indexed challengeIndex, address asserter, address challenger, uint64 challengedNode ); event UserStakeUpdated(address indexed user, uint256 initialBalance, uint256 finalBalance); event UserWithdrawableFundsUpdated( address indexed user, uint256 initialBalance, uint256 finalBalance ); function confirmPeriodBlocks() external view returns (uint64); function extraChallengeTimeBlocks() external view returns (uint64); function chainId() external view returns (uint256); function baseStake() external view returns (uint256); function wasmModuleRoot() external view returns (bytes32); function bridge() external view returns (IBridge); function sequencerInbox() external view returns (ISequencerInbox); function outbox() external view returns (IOutbox); function rollupEventInbox() external view returns (IRollupEventInbox); function challengeManager() external view returns (IChallengeManager); function loserStakeEscrow() external view returns (address); function stakeToken() external view returns (address); function minimumAssertionPeriod() external view returns (uint256); function isValidator(address) external view returns (bool); function validatorWhitelistDisabled() external view returns (bool); /** * @notice Get the Node for the given index. */ function getNode(uint64 nodeNum) external view returns (Node memory); /** * @notice Returns the block in which the given node was created for looking up its creation event. * Unlike the Node's createdAtBlock field, this will be the ArbSys blockNumber if the host chain is an Arbitrum chain. * That means that the block number returned for this is usable for event queries. * This function will revert if the given node number does not exist. * @dev This function is meant for internal use only and has no stability guarantees. */ function getNodeCreationBlockForLogLookup(uint64 nodeNum) external view returns (uint256); /** * @notice Check if the specified node has been staked on by the provided staker. * Only accurate at the latest confirmed node and afterwards. */ function nodeHasStaker(uint64 nodeNum, address staker) external view returns (bool); /** * @notice Get the address of the staker at the given index * @param stakerNum Index of the staker * @return Address of the staker */ function getStakerAddress(uint64 stakerNum) external view returns (address); /** * @notice Check whether the given staker is staked * @param staker Staker address to check * @return True or False for whether the staker was staked */ function isStaked(address staker) external view returns (bool); /** * @notice Get the latest staked node of the given staker * @param staker Staker address to lookup * @return Latest node staked of the staker */ function latestStakedNode(address staker) external view returns (uint64); /** * @notice Get the current challenge of the given staker * @param staker Staker address to lookup * @return Current challenge of the staker */ function currentChallenge(address staker) external view returns (uint64); /** * @notice Get the amount staked of the given staker * @param staker Staker address to lookup * @return Amount staked of the staker */ function amountStaked(address staker) external view returns (uint256); /** * @notice Retrieves stored information about a requested staker * @param staker Staker address to retrieve * @return A structure with information about the requested staker */ function getStaker(address staker) external view returns (Staker memory); /** * @notice Get the original staker address of the zombie at the given index * @param zombieNum Index of the zombie to lookup * @return Original staker address of the zombie */ function zombieAddress(uint256 zombieNum) external view returns (address); /** * @notice Get Latest node that the given zombie at the given index is staked on * @param zombieNum Index of the zombie to lookup * @return Latest node that the given zombie is staked on */ function zombieLatestStakedNode(uint256 zombieNum) external view returns (uint64); /// @return Current number of un-removed zombies function zombieCount() external view returns (uint256); function isZombie(address staker) external view returns (bool); /** * @notice Get the amount of funds withdrawable by the given address * @param owner Address to check the funds of * @return Amount of funds withdrawable by owner */ function withdrawableFunds(address owner) external view returns (uint256); /** * @return Index of the first unresolved node * @dev If all nodes have been resolved, this will be latestNodeCreated + 1 */ function firstUnresolvedNode() external view returns (uint64); /// @return Index of the latest confirmed node function latestConfirmed() external view returns (uint64); /// @return Index of the latest rollup node created function latestNodeCreated() external view returns (uint64); /// @return Ethereum block that the most recent stake was created function lastStakeBlock() external view returns (uint64); /// @return Number of active stakers currently staked function stakerCount() external view returns (uint64); }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../bridge/IBridge.sol"; interface IRollupEventInbox { function bridge() external view returns (IBridge); function initialize(IBridge _bridge) external; function rollup() external view returns (address); function updateRollupAddress() external; function rollupInitialized(uint256 chainId, string calldata chainConfig) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./IRollupCore.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IOutbox.sol"; import "../bridge/IOwnable.sol"; interface IRollupUserAbs is IRollupCore, IOwnable { /// @dev the user logic just validated configuration and shouldn't write to state during init /// this allows the admin logic to ensure consistency on parameters. function initialize(address stakeToken) external view; function removeWhitelistAfterFork() external; function removeWhitelistAfterValidatorAfk() external; function isERC20Enabled() external view returns (bool); function rejectNextNode(address stakerAddress) external; function confirmNextNode(bytes32 blockHash, bytes32 sendRoot) external; function stakeOnExistingNode(uint64 nodeNum, bytes32 nodeHash) external; function stakeOnNewNode( Assertion memory assertion, bytes32 expectedNodeHash, uint256 prevNodeInboxMaxCount ) external; function returnOldDeposit(address stakerAddress) external; function reduceDeposit(uint256 target) external; function removeZombie(uint256 zombieNum, uint256 maxNodes) external; function removeOldZombies(uint256 startIndex) external; function requiredStake( uint256 blockNumber, uint64 firstUnresolvedNodeNum, uint64 latestCreatedNode ) external view returns (uint256); function currentRequiredStake() external view returns (uint256); function countStakedZombies(uint64 nodeNum) external view returns (uint256); function countZombiesStakedOnChildren(uint64 nodeNum) external view returns (uint256); function requireUnresolvedExists() external view; function requireUnresolved(uint256 nodeNum) external view; function withdrawStakerFunds() external returns (uint256); function createChallenge( address[2] calldata stakers, uint64[2] calldata nodeNums, MachineStatus[2] calldata machineStatuses, GlobalState[2] calldata globalStates, uint64 numBlocks, bytes32 secondExecutionHash, uint256[2] calldata proposedTimes, bytes32[2] calldata wasmModuleRoots ) external; } interface IRollupUser is IRollupUserAbs { function newStakeOnExistingNode(uint64 nodeNum, bytes32 nodeHash) external payable; function newStakeOnNewNode( Assertion calldata assertion, bytes32 expectedNodeHash, uint256 prevNodeInboxMaxCount ) external payable; function addToDeposit(address stakerAddress) external payable; } interface IRollupUserERC20 is IRollupUserAbs { function newStakeOnExistingNode( uint256 tokenAmount, uint64 nodeNum, bytes32 nodeHash ) external; function newStakeOnNewNode( uint256 tokenAmount, Assertion calldata assertion, bytes32 expectedNodeHash, uint256 prevNodeInboxMaxCount ) external; function addToDeposit(address stakerAddress, uint256 tokenAmount) external; }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../state/GlobalState.sol"; import "../state/Machine.sol"; struct ExecutionState { GlobalState globalState; MachineStatus machineStatus; } struct Assertion { ExecutionState beforeState; ExecutionState afterState; uint64 numBlocks; } struct Node { // Hash of the state of the chain as of this node bytes32 stateHash; // Hash of the data that can be challenged bytes32 challengeHash; // Hash of the data that will be committed if this node is confirmed bytes32 confirmData; // Index of the node previous to this one uint64 prevNum; // Deadline at which this node can be confirmed uint64 deadlineBlock; // Deadline at which a child of this node can be confirmed uint64 noChildConfirmedBeforeBlock; // Number of stakers staked on this node. This includes real stakers and zombies uint64 stakerCount; // Number of stakers staked on a child node. This includes real stakers and zombies uint64 childStakerCount; // This value starts at zero and is set to a value when the first child is created. After that it is constant until the node is destroyed or the owner destroys pending nodes uint64 firstChildBlock; // The number of the latest child of this node to be created uint64 latestChildNumber; // The block number when this node was created uint64 createdAtBlock; // A hash of all the data needed to determine this node's validity, to protect against reorgs bytes32 nodeHash; } /** * @notice Utility functions for Node */ library NodeLib { /** * @notice Initialize a Node * @param _stateHash Initial value of stateHash * @param _challengeHash Initial value of challengeHash * @param _confirmData Initial value of confirmData * @param _prevNum Initial value of prevNum * @param _deadlineBlock Initial value of deadlineBlock * @param _nodeHash Initial value of nodeHash */ function createNode( bytes32 _stateHash, bytes32 _challengeHash, bytes32 _confirmData, uint64 _prevNum, uint64 _deadlineBlock, bytes32 _nodeHash ) internal view returns (Node memory) { Node memory node; node.stateHash = _stateHash; node.challengeHash = _challengeHash; node.confirmData = _confirmData; node.prevNum = _prevNum; node.deadlineBlock = _deadlineBlock; node.noChildConfirmedBeforeBlock = _deadlineBlock; node.createdAtBlock = uint64(block.number); node.nodeHash = _nodeHash; return node; } /** * @notice Update child properties * @param number The child number to set */ function childCreated(Node storage self, uint64 number) internal { if (self.firstChildBlock == 0) { self.firstChildBlock = uint64(block.number); } self.latestChildNumber = number; } /** * @notice Update the child confirmed deadline * @param deadline The new deadline to set */ function newChildConfirmDeadline(Node storage self, uint64 deadline) internal { self.noChildConfirmedBeforeBlock = deadline; } /** * @notice Check whether the current block number has met or passed the node's deadline */ function requirePastDeadline(Node memory self) internal view { require(block.number >= self.deadlineBlock, "BEFORE_DEADLINE"); } /** * @notice Check whether the current block number has met or passed deadline for children of this node to be confirmed */ function requirePastChildConfirmDeadline(Node memory self) internal view { require(block.number >= self.noChildConfirmedBeforeBlock, "CHILD_TOO_RECENT"); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "./Node.sol"; import "./RollupLib.sol"; import "./IRollupEventInbox.sol"; import "./IRollupCore.sol"; import "../challenge/IChallengeManager.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IBridge.sol"; import "../bridge/IOutbox.sol"; import "../precompiles/ArbSys.sol"; import "../libraries/ArbitrumChecker.sol"; import {NO_CHAL_INDEX} from "../libraries/Constants.sol"; abstract contract RollupCore is IRollupCore, PausableUpgradeable { using NodeLib for Node; using GlobalStateLib for GlobalState; // Rollup Config uint64 public confirmPeriodBlocks; uint64 public extraChallengeTimeBlocks; uint256 public chainId; uint256 public baseStake; bytes32 public wasmModuleRoot; IInboxBase public inbox; IBridge public bridge; IOutbox public outbox; ISequencerInbox public sequencerInbox; IRollupEventInbox public rollupEventInbox; IChallengeManager public override challengeManager; // misc useful contracts when interacting with the rollup address public validatorUtils; address public validatorWalletCreator; // when a staker loses a challenge, half of their funds get escrowed in this address address public loserStakeEscrow; address public stakeToken; uint256 public minimumAssertionPeriod; mapping(address => bool) public isValidator; // Stakers become Zombies after losing a challenge struct Zombie { address stakerAddress; uint64 latestStakedNode; } uint64 private _latestConfirmed; uint64 private _firstUnresolvedNode; uint64 private _latestNodeCreated; uint64 private _lastStakeBlock; mapping(uint64 => Node) private _nodes; mapping(uint64 => mapping(address => bool)) private _nodeStakers; address[] private _stakerList; mapping(address => Staker) public _stakerMap; Zombie[] private _zombies; mapping(address => uint256) private _withdrawableFunds; uint256 public totalWithdrawableFunds; uint256 public rollupDeploymentBlock; // The node number of the initial node uint64 internal constant GENESIS_NODE = 0; bool public validatorWhitelistDisabled; // If the chain this RollupCore is deployed on is an Arbitrum chain. bool internal immutable _hostChainIsArbitrum = ArbitrumChecker.runningOnArbitrum(); // If the chain RollupCore is deployed on, this will contain the ArbSys.blockNumber() at each node's creation. mapping(uint64 => uint256) internal _nodeCreatedAtArbSysBlock; /** * @notice Get a storage reference to the Node for the given node index * @param nodeNum Index of the node * @return Node struct */ function getNodeStorage(uint64 nodeNum) internal view returns (Node storage) { return _nodes[nodeNum]; } /** * @notice Get the Node for the given index. */ function getNode(uint64 nodeNum) public view override returns (Node memory) { return getNodeStorage(nodeNum); } /** * @notice Returns the block in which the given node was created for looking up its creation event. * Unlike the Node's createdAtBlock field, this will be the ArbSys blockNumber if the host chain is an Arbitrum chain. * That means that the block number returned for this is usable for event queries. * This function will revert if the given node number does not exist. * @dev This function is meant for internal use only and has no stability guarantees. */ function getNodeCreationBlockForLogLookup(uint64 nodeNum) external view override returns (uint256) { if (_hostChainIsArbitrum) { uint256 blockNum = _nodeCreatedAtArbSysBlock[nodeNum]; require(blockNum > 0, "NO_NODE"); return blockNum; } else { Node storage node = getNodeStorage(nodeNum); require(node.deadlineBlock != 0, "NO_NODE"); return node.createdAtBlock; } } /** * @notice Check if the specified node has been staked on by the provided staker. * Only accurate at the latest confirmed node and afterwards. */ function nodeHasStaker(uint64 nodeNum, address staker) public view override returns (bool) { return _nodeStakers[nodeNum][staker]; } /** * @notice Get the address of the staker at the given index * @param stakerNum Index of the staker * @return Address of the staker */ function getStakerAddress(uint64 stakerNum) external view override returns (address) { return _stakerList[stakerNum]; } /** * @notice Check whether the given staker is staked * @param staker Staker address to check * @return True or False for whether the staker was staked */ function isStaked(address staker) public view override returns (bool) { return _stakerMap[staker].isStaked; } /** * @notice Check whether the given staker is staked on the latest confirmed node, * which includes if the staker is staked on a descendent of the latest confirmed node. * @param staker Staker address to check * @return True or False for whether the staker was staked */ function isStakedOnLatestConfirmed(address staker) public view returns (bool) { return _stakerMap[staker].isStaked && nodeHasStaker(_latestConfirmed, staker); } /** * @notice Get the latest staked node of the given staker * @param staker Staker address to lookup * @return Latest node staked of the staker */ function latestStakedNode(address staker) public view override returns (uint64) { return _stakerMap[staker].latestStakedNode; } /** * @notice Get the current challenge of the given staker * @param staker Staker address to lookup * @return Current challenge of the staker */ function currentChallenge(address staker) public view override returns (uint64) { return _stakerMap[staker].currentChallenge; } /** * @notice Get the amount staked of the given staker * @param staker Staker address to lookup * @return Amount staked of the staker */ function amountStaked(address staker) public view override returns (uint256) { return _stakerMap[staker].amountStaked; } /** * @notice Retrieves stored information about a requested staker * @param staker Staker address to retrieve * @return A structure with information about the requested staker */ function getStaker(address staker) external view override returns (Staker memory) { return _stakerMap[staker]; } /** * @notice Get the original staker address of the zombie at the given index * @param zombieNum Index of the zombie to lookup * @return Original staker address of the zombie */ function zombieAddress(uint256 zombieNum) public view override returns (address) { return _zombies[zombieNum].stakerAddress; } /** * @notice Get Latest node that the given zombie at the given index is staked on * @param zombieNum Index of the zombie to lookup * @return Latest node that the given zombie is staked on */ function zombieLatestStakedNode(uint256 zombieNum) public view override returns (uint64) { return _zombies[zombieNum].latestStakedNode; } /** * @notice Retrieves stored information about a requested zombie * @param zombieNum Index of the zombie to lookup * @return A structure with information about the requested staker */ function getZombieStorage(uint256 zombieNum) internal view returns (Zombie storage) { return _zombies[zombieNum]; } /// @return Current number of un-removed zombies function zombieCount() public view override returns (uint256) { return _zombies.length; } function isZombie(address staker) public view override returns (bool) { for (uint256 i = 0; i < _zombies.length; i++) { if (staker == _zombies[i].stakerAddress) { return true; } } return false; } /** * @notice Get the amount of funds withdrawable by the given address * @param user Address to check the funds of * @return Amount of funds withdrawable by user */ function withdrawableFunds(address user) external view override returns (uint256) { return _withdrawableFunds[user]; } /** * @return Index of the first unresolved node * @dev If all nodes have been resolved, this will be latestNodeCreated + 1 */ function firstUnresolvedNode() public view override returns (uint64) { return _firstUnresolvedNode; } /// @return Index of the latest confirmed node function latestConfirmed() public view override returns (uint64) { return _latestConfirmed; } /// @return Index of the latest rollup node created function latestNodeCreated() public view override returns (uint64) { return _latestNodeCreated; } /// @return Ethereum block that the most recent stake was created function lastStakeBlock() external view override returns (uint64) { return _lastStakeBlock; } /// @return Number of active stakers currently staked function stakerCount() public view override returns (uint64) { return uint64(_stakerList.length); } /** * @notice Initialize the core with an initial node * @param initialNode Initial node to start the chain with */ function initializeCore(Node memory initialNode) internal { __Pausable_init(); _nodes[GENESIS_NODE] = initialNode; _firstUnresolvedNode = GENESIS_NODE + 1; if (_hostChainIsArbitrum) { _nodeCreatedAtArbSysBlock[GENESIS_NODE] = ArbSys(address(100)).arbBlockNumber(); } } /** * @notice React to a new node being created by storing it an incrementing the latest node counter * @param node Node that was newly created */ function nodeCreated(Node memory node) internal { _latestNodeCreated++; _nodes[_latestNodeCreated] = node; if (_hostChainIsArbitrum) { _nodeCreatedAtArbSysBlock[_latestNodeCreated] = ArbSys(address(100)).arbBlockNumber(); } } /// @notice Reject the next unresolved node function _rejectNextNode() internal { _firstUnresolvedNode++; } function confirmNode( uint64 nodeNum, bytes32 blockHash, bytes32 sendRoot ) internal { Node storage node = getNodeStorage(nodeNum); // Authenticate data against node's confirm data pre-image require(node.confirmData == RollupLib.confirmHash(blockHash, sendRoot), "CONFIRM_DATA"); // trusted external call to outbox outbox.updateSendRoot(sendRoot, blockHash); _latestConfirmed = nodeNum; _firstUnresolvedNode = nodeNum + 1; emit NodeConfirmed(nodeNum, blockHash, sendRoot); } /** * @notice Create a new stake at latest confirmed node * @param stakerAddress Address of the new staker * @param depositAmount Stake amount of the new staker */ function createNewStake(address stakerAddress, uint256 depositAmount) internal { uint64 stakerIndex = uint64(_stakerList.length); _stakerList.push(stakerAddress); _stakerMap[stakerAddress] = Staker( depositAmount, stakerIndex, _latestConfirmed, NO_CHAL_INDEX, // new staker is not in challenge true ); _nodeStakers[_latestConfirmed][stakerAddress] = true; _lastStakeBlock = uint64(block.number); emit UserStakeUpdated(stakerAddress, 0, depositAmount); } /** * @notice Check to see whether the two stakers are in the same challenge * @param stakerAddress1 Address of the first staker * @param stakerAddress2 Address of the second staker * @return Address of the challenge that the two stakers are in */ function inChallenge(address stakerAddress1, address stakerAddress2) internal view returns (uint64) { Staker storage staker1 = _stakerMap[stakerAddress1]; Staker storage staker2 = _stakerMap[stakerAddress2]; uint64 challenge = staker1.currentChallenge; require(challenge != NO_CHAL_INDEX, "NO_CHAL"); require(challenge == staker2.currentChallenge, "DIFF_IN_CHAL"); return challenge; } /** * @notice Make the given staker as not being in a challenge * @param stakerAddress Address of the staker to remove from a challenge */ function clearChallenge(address stakerAddress) internal { Staker storage staker = _stakerMap[stakerAddress]; staker.currentChallenge = NO_CHAL_INDEX; } /** * @notice Mark both the given stakers as engaged in the challenge * @param staker1 Address of the first staker * @param staker2 Address of the second staker * @param challenge Address of the challenge both stakers are now in */ function challengeStarted( address staker1, address staker2, uint64 challenge ) internal { _stakerMap[staker1].currentChallenge = challenge; _stakerMap[staker2].currentChallenge = challenge; } /** * @notice Add to the stake of the given staker by the given amount * @param stakerAddress Address of the staker to increase the stake of * @param amountAdded Amount of stake to add to the staker */ function increaseStakeBy(address stakerAddress, uint256 amountAdded) internal { Staker storage staker = _stakerMap[stakerAddress]; uint256 initialStaked = staker.amountStaked; uint256 finalStaked = initialStaked + amountAdded; staker.amountStaked = finalStaked; emit UserStakeUpdated(stakerAddress, initialStaked, finalStaked); } /** * @notice Reduce the stake of the given staker to the given target * @param stakerAddress Address of the staker to reduce the stake of * @param target Amount of stake to leave with the staker * @return Amount of value released from the stake */ function reduceStakeTo(address stakerAddress, uint256 target) internal returns (uint256) { Staker storage staker = _stakerMap[stakerAddress]; uint256 current = staker.amountStaked; require(target <= current, "TOO_LITTLE_STAKE"); uint256 amountWithdrawn = current - target; staker.amountStaked = target; increaseWithdrawableFunds(stakerAddress, amountWithdrawn); emit UserStakeUpdated(stakerAddress, current, target); return amountWithdrawn; } /** * @notice Remove the given staker and turn them into a zombie * @param stakerAddress Address of the staker to remove */ function turnIntoZombie(address stakerAddress) internal { Staker storage staker = _stakerMap[stakerAddress]; _zombies.push(Zombie(stakerAddress, staker.latestStakedNode)); deleteStaker(stakerAddress); } /** * @notice Update the latest staked node of the zombie at the given index * @param zombieNum Index of the zombie to move * @param latest New latest node the zombie is staked on */ function zombieUpdateLatestStakedNode(uint256 zombieNum, uint64 latest) internal { _zombies[zombieNum].latestStakedNode = latest; } /** * @notice Remove the zombie at the given index * @param zombieNum Index of the zombie to remove */ function removeZombie(uint256 zombieNum) internal { _zombies[zombieNum] = _zombies[_zombies.length - 1]; _zombies.pop(); } /** * @notice Mark the given staker as staked on this node * @param staker Address of the staker to mark */ function addStaker(uint64 nodeNum, address staker) internal { require(!_nodeStakers[nodeNum][staker], "ALREADY_STAKED"); _nodeStakers[nodeNum][staker] = true; Node storage node = getNodeStorage(nodeNum); require(node.deadlineBlock != 0, "NO_NODE"); uint64 prevCount = node.stakerCount; node.stakerCount = prevCount + 1; if (nodeNum > GENESIS_NODE) { Node storage parent = getNodeStorage(node.prevNum); parent.childStakerCount++; if (prevCount == 0) { parent.newChildConfirmDeadline(uint64(block.number) + confirmPeriodBlocks); } } } /** * @notice Remove the given staker from this node * @param staker Address of the staker to remove */ function removeStaker(uint64 nodeNum, address staker) internal { require(_nodeStakers[nodeNum][staker], "NOT_STAKED"); _nodeStakers[nodeNum][staker] = false; Node storage node = getNodeStorage(nodeNum); node.stakerCount--; if (nodeNum > GENESIS_NODE) { getNodeStorage(node.prevNum).childStakerCount--; } } /** * @notice Remove the given staker and return their stake * This should not be called if the staker is staked on a descendent of the latest confirmed node * @param stakerAddress Address of the staker withdrawing their stake */ function withdrawStaker(address stakerAddress) internal { Staker storage staker = _stakerMap[stakerAddress]; uint64 latestConfirmedNum = latestConfirmed(); if (nodeHasStaker(latestConfirmedNum, stakerAddress)) { // Withdrawing a staker whose latest staked node isn't resolved should be impossible assert(staker.latestStakedNode == latestConfirmedNum); removeStaker(latestConfirmedNum, stakerAddress); } uint256 initialStaked = staker.amountStaked; increaseWithdrawableFunds(stakerAddress, initialStaked); deleteStaker(stakerAddress); emit UserStakeUpdated(stakerAddress, initialStaked, 0); } /** * @notice Advance the given staker to the given node * @param stakerAddress Address of the staker adding their stake * @param nodeNum Index of the node to stake on */ function stakeOnNode(address stakerAddress, uint64 nodeNum) internal { Staker storage staker = _stakerMap[stakerAddress]; addStaker(nodeNum, stakerAddress); staker.latestStakedNode = nodeNum; } /** * @notice Clear the withdrawable funds for the given address * @param account Address of the account to remove funds from * @return Amount of funds removed from account */ function withdrawFunds(address account) internal returns (uint256) { uint256 amount = _withdrawableFunds[account]; _withdrawableFunds[account] = 0; totalWithdrawableFunds -= amount; emit UserWithdrawableFundsUpdated(account, amount, 0); return amount; } /** * @notice Increase the withdrawable funds for the given address * @param account Address of the account to add withdrawable funds to */ function increaseWithdrawableFunds(address account, uint256 amount) internal { uint256 initialWithdrawable = _withdrawableFunds[account]; uint256 finalWithdrawable = initialWithdrawable + amount; _withdrawableFunds[account] = finalWithdrawable; totalWithdrawableFunds += amount; emit UserWithdrawableFundsUpdated(account, initialWithdrawable, finalWithdrawable); } /** * @notice Remove the given staker * @param stakerAddress Address of the staker to remove */ function deleteStaker(address stakerAddress) private { Staker storage staker = _stakerMap[stakerAddress]; require(staker.isStaked, "NOT_STAKED"); uint64 stakerIndex = staker.index; _stakerList[stakerIndex] = _stakerList[_stakerList.length - 1]; _stakerMap[_stakerList[stakerIndex]].index = stakerIndex; _stakerList.pop(); delete _stakerMap[stakerAddress]; } struct StakeOnNewNodeFrame { uint256 currentInboxSize; Node node; bytes32 executionHash; Node prevNode; bytes32 lastHash; bool hasSibling; uint64 deadlineBlock; bytes32 sequencerBatchAcc; } function createNewNode( Assertion calldata assertion, uint64 prevNodeNum, uint256 prevNodeInboxMaxCount, bytes32 expectedNodeHash ) internal returns (bytes32 newNodeHash) { require( assertion.afterState.machineStatus == MachineStatus.FINISHED || assertion.afterState.machineStatus == MachineStatus.ERRORED, "BAD_AFTER_STATUS" ); StakeOnNewNodeFrame memory memoryFrame; { // validate data memoryFrame.prevNode = getNode(prevNodeNum); memoryFrame.currentInboxSize = bridge.sequencerMessageCount(); // Make sure the previous state is correct against the node being built on require( RollupLib.stateHash(assertion.beforeState, prevNodeInboxMaxCount) == memoryFrame.prevNode.stateHash, "PREV_STATE_HASH" ); // Ensure that the assertion doesn't read past the end of the current inbox uint64 afterInboxCount = assertion.afterState.globalState.getInboxPosition(); uint64 prevInboxPosition = assertion.beforeState.globalState.getInboxPosition(); require(afterInboxCount >= prevInboxPosition, "INBOX_BACKWARDS"); if (afterInboxCount == prevInboxPosition) { require( assertion.afterState.globalState.getPositionInMessage() >= assertion.beforeState.globalState.getPositionInMessage(), "INBOX_POS_IN_MSG_BACKWARDS" ); } // See validator/assertion.go ExecutionState RequiredBatches() for reasoning if ( assertion.afterState.machineStatus == MachineStatus.ERRORED || assertion.afterState.globalState.getPositionInMessage() > 0 ) { // The current inbox message was read afterInboxCount++; } require(afterInboxCount <= memoryFrame.currentInboxSize, "INBOX_PAST_END"); // This gives replay protection against the state of the inbox if (afterInboxCount > 0) { memoryFrame.sequencerBatchAcc = bridge.sequencerInboxAccs(afterInboxCount - 1); } } { memoryFrame.executionHash = RollupLib.executionHash(assertion); memoryFrame.deadlineBlock = uint64(block.number) + confirmPeriodBlocks; memoryFrame.hasSibling = memoryFrame.prevNode.latestChildNumber > 0; // here we don't use ternacy operator to remain compatible with slither if (memoryFrame.hasSibling) { memoryFrame.lastHash = getNodeStorage(memoryFrame.prevNode.latestChildNumber) .nodeHash; } else { memoryFrame.lastHash = memoryFrame.prevNode.nodeHash; } newNodeHash = RollupLib.nodeHash( memoryFrame.hasSibling, memoryFrame.lastHash, memoryFrame.executionHash, memoryFrame.sequencerBatchAcc, wasmModuleRoot ); require( newNodeHash == expectedNodeHash || expectedNodeHash == bytes32(0), "UNEXPECTED_NODE_HASH" ); memoryFrame.node = NodeLib.createNode( RollupLib.stateHash(assertion.afterState, memoryFrame.currentInboxSize), RollupLib.challengeRootHash( memoryFrame.executionHash, block.number, wasmModuleRoot ), RollupLib.confirmHash(assertion), prevNodeNum, memoryFrame.deadlineBlock, newNodeHash ); } { uint64 nodeNum = latestNodeCreated() + 1; // Fetch a storage reference to prevNode since we copied our other one into memory // and we don't have enough stack available to keep to keep the previous storage reference around Node storage prevNode = getNodeStorage(prevNodeNum); prevNode.childCreated(nodeNum); nodeCreated(memoryFrame.node); } emit NodeCreated( latestNodeCreated(), memoryFrame.prevNode.nodeHash, newNodeHash, memoryFrame.executionHash, assertion, memoryFrame.sequencerBatchAcc, wasmModuleRoot, memoryFrame.currentInboxSize ); return newNodeHash; } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../challenge/IChallengeManager.sol"; import "../challenge/ChallengeLib.sol"; import "../state/GlobalState.sol"; import "../bridge/ISequencerInbox.sol"; import "../bridge/IBridge.sol"; import "../bridge/IOutbox.sol"; import "../bridge/IInboxBase.sol"; import "./Node.sol"; import "./IRollupEventInbox.sol"; library RollupLib { using GlobalStateLib for GlobalState; function stateHash(ExecutionState calldata execState, uint256 inboxMaxCount) internal pure returns (bytes32) { return keccak256( abi.encodePacked( execState.globalState.hash(), inboxMaxCount, execState.machineStatus ) ); } /// @dev same as stateHash but expects execState in memory instead of calldata function stateHashMem(ExecutionState memory execState, uint256 inboxMaxCount) internal pure returns (bytes32) { return keccak256( abi.encodePacked( execState.globalState.hash(), inboxMaxCount, execState.machineStatus ) ); } function executionHash(Assertion memory assertion) internal pure returns (bytes32) { MachineStatus[2] memory statuses; statuses[0] = assertion.beforeState.machineStatus; statuses[1] = assertion.afterState.machineStatus; GlobalState[2] memory globalStates; globalStates[0] = assertion.beforeState.globalState; globalStates[1] = assertion.afterState.globalState; // TODO: benchmark how much this abstraction adds of gas overhead return executionHash(statuses, globalStates, assertion.numBlocks); } function executionHash( MachineStatus[2] memory statuses, GlobalState[2] memory globalStates, uint64 numBlocks ) internal pure returns (bytes32) { bytes32[] memory segments = new bytes32[](2); segments[0] = ChallengeLib.blockStateHash(statuses[0], globalStates[0].hash()); segments[1] = ChallengeLib.blockStateHash(statuses[1], globalStates[1].hash()); return ChallengeLib.hashChallengeState(0, numBlocks, segments); } function challengeRootHash( bytes32 execution, uint256 proposedTime, bytes32 wasmModuleRoot ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(execution, proposedTime, wasmModuleRoot)); } function confirmHash(Assertion memory assertion) internal pure returns (bytes32) { return confirmHash( assertion.afterState.globalState.getBlockHash(), assertion.afterState.globalState.getSendRoot() ); } function confirmHash(bytes32 blockHash, bytes32 sendRoot) internal pure returns (bytes32) { return keccak256(abi.encodePacked(blockHash, sendRoot)); } function nodeHash( bool hasSibling, bytes32 lastHash, bytes32 assertionExecHash, bytes32 inboxAcc, bytes32 wasmModuleRoot ) internal pure returns (bytes32) { uint8 hasSiblingInt = hasSibling ? 1 : 0; return keccak256( abi.encodePacked( hasSiblingInt, lastHash, assertionExecHash, inboxAcc, wasmModuleRoot ) ); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; struct GlobalState { bytes32[2] bytes32Vals; uint64[2] u64Vals; } library GlobalStateLib { uint16 internal constant BYTES32_VALS_NUM = 2; uint16 internal constant U64_VALS_NUM = 2; function hash(GlobalState memory state) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Global state:", state.bytes32Vals[0], state.bytes32Vals[1], state.u64Vals[0], state.u64Vals[1] ) ); } function getBlockHash(GlobalState memory state) internal pure returns (bytes32) { return state.bytes32Vals[0]; } function getSendRoot(GlobalState memory state) internal pure returns (bytes32) { return state.bytes32Vals[1]; } function getInboxPosition(GlobalState memory state) internal pure returns (uint64) { return state.u64Vals[0]; } function getPositionInMessage(GlobalState memory state) internal pure returns (uint64) { return state.u64Vals[1]; } function isEmpty(GlobalState calldata state) internal pure returns (bool) { return (state.bytes32Vals[0] == bytes32(0) && state.bytes32Vals[1] == bytes32(0) && state.u64Vals[0] == 0 && state.u64Vals[1] == 0); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; struct Instruction { uint16 opcode; uint256 argumentData; } library Instructions { uint16 internal constant UNREACHABLE = 0x00; uint16 internal constant NOP = 0x01; uint16 internal constant RETURN = 0x0F; uint16 internal constant CALL = 0x10; uint16 internal constant CALL_INDIRECT = 0x11; uint16 internal constant LOCAL_GET = 0x20; uint16 internal constant LOCAL_SET = 0x21; uint16 internal constant GLOBAL_GET = 0x23; uint16 internal constant GLOBAL_SET = 0x24; uint16 internal constant I32_LOAD = 0x28; uint16 internal constant I64_LOAD = 0x29; uint16 internal constant F32_LOAD = 0x2A; uint16 internal constant F64_LOAD = 0x2B; uint16 internal constant I32_LOAD8_S = 0x2C; uint16 internal constant I32_LOAD8_U = 0x2D; uint16 internal constant I32_LOAD16_S = 0x2E; uint16 internal constant I32_LOAD16_U = 0x2F; uint16 internal constant I64_LOAD8_S = 0x30; uint16 internal constant I64_LOAD8_U = 0x31; uint16 internal constant I64_LOAD16_S = 0x32; uint16 internal constant I64_LOAD16_U = 0x33; uint16 internal constant I64_LOAD32_S = 0x34; uint16 internal constant I64_LOAD32_U = 0x35; uint16 internal constant I32_STORE = 0x36; uint16 internal constant I64_STORE = 0x37; uint16 internal constant F32_STORE = 0x38; uint16 internal constant F64_STORE = 0x39; uint16 internal constant I32_STORE8 = 0x3A; uint16 internal constant I32_STORE16 = 0x3B; uint16 internal constant I64_STORE8 = 0x3C; uint16 internal constant I64_STORE16 = 0x3D; uint16 internal constant I64_STORE32 = 0x3E; uint16 internal constant MEMORY_SIZE = 0x3F; uint16 internal constant MEMORY_GROW = 0x40; uint16 internal constant DROP = 0x1A; uint16 internal constant SELECT = 0x1B; uint16 internal constant I32_CONST = 0x41; uint16 internal constant I64_CONST = 0x42; uint16 internal constant F32_CONST = 0x43; uint16 internal constant F64_CONST = 0x44; uint16 internal constant I32_EQZ = 0x45; uint16 internal constant I32_RELOP_BASE = 0x46; uint16 internal constant IRELOP_EQ = 0; uint16 internal constant IRELOP_NE = 1; uint16 internal constant IRELOP_LT_S = 2; uint16 internal constant IRELOP_LT_U = 3; uint16 internal constant IRELOP_GT_S = 4; uint16 internal constant IRELOP_GT_U = 5; uint16 internal constant IRELOP_LE_S = 6; uint16 internal constant IRELOP_LE_U = 7; uint16 internal constant IRELOP_GE_S = 8; uint16 internal constant IRELOP_GE_U = 9; uint16 internal constant IRELOP_LAST = IRELOP_GE_U; uint16 internal constant I64_EQZ = 0x50; uint16 internal constant I64_RELOP_BASE = 0x51; uint16 internal constant I32_UNOP_BASE = 0x67; uint16 internal constant IUNOP_CLZ = 0; uint16 internal constant IUNOP_CTZ = 1; uint16 internal constant IUNOP_POPCNT = 2; uint16 internal constant IUNOP_LAST = IUNOP_POPCNT; uint16 internal constant I32_ADD = 0x6A; uint16 internal constant I32_SUB = 0x6B; uint16 internal constant I32_MUL = 0x6C; uint16 internal constant I32_DIV_S = 0x6D; uint16 internal constant I32_DIV_U = 0x6E; uint16 internal constant I32_REM_S = 0x6F; uint16 internal constant I32_REM_U = 0x70; uint16 internal constant I32_AND = 0x71; uint16 internal constant I32_OR = 0x72; uint16 internal constant I32_XOR = 0x73; uint16 internal constant I32_SHL = 0x74; uint16 internal constant I32_SHR_S = 0x75; uint16 internal constant I32_SHR_U = 0x76; uint16 internal constant I32_ROTL = 0x77; uint16 internal constant I32_ROTR = 0x78; uint16 internal constant I64_UNOP_BASE = 0x79; uint16 internal constant I64_ADD = 0x7C; uint16 internal constant I64_SUB = 0x7D; uint16 internal constant I64_MUL = 0x7E; uint16 internal constant I64_DIV_S = 0x7F; uint16 internal constant I64_DIV_U = 0x80; uint16 internal constant I64_REM_S = 0x81; uint16 internal constant I64_REM_U = 0x82; uint16 internal constant I64_AND = 0x83; uint16 internal constant I64_OR = 0x84; uint16 internal constant I64_XOR = 0x85; uint16 internal constant I64_SHL = 0x86; uint16 internal constant I64_SHR_S = 0x87; uint16 internal constant I64_SHR_U = 0x88; uint16 internal constant I64_ROTL = 0x89; uint16 internal constant I64_ROTR = 0x8A; uint16 internal constant I32_WRAP_I64 = 0xA7; uint16 internal constant I64_EXTEND_I32_S = 0xAC; uint16 internal constant I64_EXTEND_I32_U = 0xAD; uint16 internal constant I32_REINTERPRET_F32 = 0xBC; uint16 internal constant I64_REINTERPRET_F64 = 0xBD; uint16 internal constant F32_REINTERPRET_I32 = 0xBE; uint16 internal constant F64_REINTERPRET_I64 = 0xBF; uint16 internal constant I32_EXTEND_8S = 0xC0; uint16 internal constant I32_EXTEND_16S = 0xC1; uint16 internal constant I64_EXTEND_8S = 0xC2; uint16 internal constant I64_EXTEND_16S = 0xC3; uint16 internal constant I64_EXTEND_32S = 0xC4; uint16 internal constant INIT_FRAME = 0x8002; uint16 internal constant ARBITRARY_JUMP = 0x8003; uint16 internal constant ARBITRARY_JUMP_IF = 0x8004; uint16 internal constant MOVE_FROM_STACK_TO_INTERNAL = 0x8005; uint16 internal constant MOVE_FROM_INTERNAL_TO_STACK = 0x8006; uint16 internal constant DUP = 0x8008; uint16 internal constant CROSS_MODULE_CALL = 0x8009; uint16 internal constant CALLER_MODULE_INTERNAL_CALL = 0x800A; uint16 internal constant GET_GLOBAL_STATE_BYTES32 = 0x8010; uint16 internal constant SET_GLOBAL_STATE_BYTES32 = 0x8011; uint16 internal constant GET_GLOBAL_STATE_U64 = 0x8012; uint16 internal constant SET_GLOBAL_STATE_U64 = 0x8013; uint16 internal constant READ_PRE_IMAGE = 0x8020; uint16 internal constant READ_INBOX_MESSAGE = 0x8021; uint16 internal constant HALT_AND_SET_FINISHED = 0x8022; uint256 internal constant INBOX_INDEX_SEQUENCER = 0; uint256 internal constant INBOX_INDEX_DELAYED = 1; function hash(Instruction memory inst) internal pure returns (bytes32) { return keccak256(abi.encodePacked("Instruction:", inst.opcode, inst.argumentData)); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./ValueStack.sol"; import "./Instructions.sol"; import "./StackFrame.sol"; enum MachineStatus { RUNNING, FINISHED, ERRORED, TOO_FAR } struct Machine { MachineStatus status; ValueStack valueStack; ValueStack internalStack; StackFrameWindow frameStack; bytes32 globalStateHash; uint32 moduleIdx; uint32 functionIdx; uint32 functionPc; bytes32 modulesRoot; } library MachineLib { using StackFrameLib for StackFrameWindow; using ValueStackLib for ValueStack; function hash(Machine memory mach) internal pure returns (bytes32) { // Warning: the non-running hashes are replicated in Challenge if (mach.status == MachineStatus.RUNNING) { return keccak256( abi.encodePacked( "Machine running:", mach.valueStack.hash(), mach.internalStack.hash(), mach.frameStack.hash(), mach.globalStateHash, mach.moduleIdx, mach.functionIdx, mach.functionPc, mach.modulesRoot ) ); } else if (mach.status == MachineStatus.FINISHED) { return keccak256(abi.encodePacked("Machine finished:", mach.globalStateHash)); } else if (mach.status == MachineStatus.ERRORED) { return keccak256(abi.encodePacked("Machine errored:")); } else if (mach.status == MachineStatus.TOO_FAR) { return keccak256(abi.encodePacked("Machine too far:")); } else { revert("BAD_MACH_STATUS"); } } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./ModuleMemoryCompact.sol"; struct Module { bytes32 globalsMerkleRoot; ModuleMemory moduleMemory; bytes32 tablesMerkleRoot; bytes32 functionsMerkleRoot; uint32 internalsOffset; } library ModuleLib { using ModuleMemoryCompactLib for ModuleMemory; function hash(Module memory mod) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Module:", mod.globalsMerkleRoot, mod.moduleMemory.hash(), mod.tablesMerkleRoot, mod.functionsMerkleRoot, mod.internalsOffset ) ); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; struct ModuleMemory { uint64 size; uint64 maxSize; bytes32 merkleRoot; } library ModuleMemoryCompactLib { function hash(ModuleMemory memory mem) internal pure returns (bytes32) { return keccak256(abi.encodePacked("Memory:", mem.size, mem.maxSize, mem.merkleRoot)); } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./Value.sol"; struct StackFrame { Value returnPc; bytes32 localsMerkleRoot; uint32 callerModule; uint32 callerModuleInternals; } struct StackFrameWindow { StackFrame[] proved; bytes32 remainingHash; } library StackFrameLib { using ValueLib for Value; function hash(StackFrame memory frame) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "Stack frame:", frame.returnPc.hash(), frame.localsMerkleRoot, frame.callerModule, frame.callerModuleInternals ) ); } function hash(StackFrameWindow memory window) internal pure returns (bytes32 h) { h = window.remainingHash; for (uint256 i = 0; i < window.proved.length; i++) { h = keccak256(abi.encodePacked("Stack frame stack:", hash(window.proved[i]), h)); } } function peek(StackFrameWindow memory window) internal pure returns (StackFrame memory) { require(window.proved.length == 1, "BAD_WINDOW_LENGTH"); return window.proved[0]; } function pop(StackFrameWindow memory window) internal pure returns (StackFrame memory frame) { require(window.proved.length == 1, "BAD_WINDOW_LENGTH"); frame = window.proved[0]; window.proved = new StackFrame[](0); } function push(StackFrameWindow memory window, StackFrame memory frame) internal pure { StackFrame[] memory newProved = new StackFrame[](window.proved.length + 1); for (uint256 i = 0; i < window.proved.length; i++) { newProved[i] = window.proved[i]; } newProved[window.proved.length] = frame; window.proved = newProved; } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; enum ValueType { I32, I64, F32, F64, REF_NULL, FUNC_REF, INTERNAL_REF } struct Value { ValueType valueType; uint256 contents; } library ValueLib { function hash(Value memory val) internal pure returns (bytes32) { return keccak256(abi.encodePacked("Value:", val.valueType, val.contents)); } function maxValueType() internal pure returns (ValueType) { return ValueType.INTERNAL_REF; } function assumeI32(Value memory val) internal pure returns (uint32) { uint256 uintval = uint256(val.contents); require(val.valueType == ValueType.I32, "NOT_I32"); require(uintval < (1 << 32), "BAD_I32"); return uint32(uintval); } function assumeI64(Value memory val) internal pure returns (uint64) { uint256 uintval = uint256(val.contents); require(val.valueType == ValueType.I64, "NOT_I64"); require(uintval < (1 << 64), "BAD_I64"); return uint64(uintval); } function newRefNull() internal pure returns (Value memory) { return Value({valueType: ValueType.REF_NULL, contents: 0}); } function newI32(uint32 x) internal pure returns (Value memory) { return Value({valueType: ValueType.I32, contents: uint256(x)}); } function newI64(uint64 x) internal pure returns (Value memory) { return Value({valueType: ValueType.I64, contents: uint256(x)}); } function newBoolean(bool x) internal pure returns (Value memory) { if (x) { return newI32(uint32(1)); } else { return newI32(uint32(0)); } } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./Value.sol"; struct ValueArray { Value[] inner; } library ValueArrayLib { function get(ValueArray memory arr, uint256 index) internal pure returns (Value memory) { return arr.inner[index]; } function set( ValueArray memory arr, uint256 index, Value memory val ) internal pure { arr.inner[index] = val; } function length(ValueArray memory arr) internal pure returns (uint256) { return arr.inner.length; } function push(ValueArray memory arr, Value memory val) internal pure { Value[] memory newInner = new Value[](arr.inner.length + 1); for (uint256 i = 0; i < arr.inner.length; i++) { newInner[i] = arr.inner[i]; } newInner[arr.inner.length] = val; arr.inner = newInner; } function pop(ValueArray memory arr) internal pure returns (Value memory popped) { popped = arr.inner[arr.inner.length - 1]; Value[] memory newInner = new Value[](arr.inner.length - 1); for (uint256 i = 0; i < newInner.length; i++) { newInner[i] = arr.inner[i]; } arr.inner = newInner; } }
// Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "./Value.sol"; import "./ValueArray.sol"; struct ValueStack { ValueArray proved; bytes32 remainingHash; } library ValueStackLib { using ValueLib for Value; using ValueArrayLib for ValueArray; function hash(ValueStack memory stack) internal pure returns (bytes32 h) { h = stack.remainingHash; uint256 len = stack.proved.length(); for (uint256 i = 0; i < len; i++) { h = keccak256(abi.encodePacked("Value stack:", stack.proved.get(i).hash(), h)); } } function peek(ValueStack memory stack) internal pure returns (Value memory) { uint256 len = stack.proved.length(); return stack.proved.get(len - 1); } function pop(ValueStack memory stack) internal pure returns (Value memory) { return stack.proved.pop(); } function push(ValueStack memory stack, Value memory val) internal pure { return stack.proved.push(val); } }
{ "optimizer": { "enabled": true, "runs": 100 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"nodeNum","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"sendRoot","type":"bytes32"}],"name":"NodeConfirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"nodeNum","type":"uint64"},{"indexed":true,"internalType":"bytes32","name":"parentNodeHash","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"nodeHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"executionHash","type":"bytes32"},{"components":[{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"beforeState","type":"tuple"},{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"afterState","type":"tuple"},{"internalType":"uint64","name":"numBlocks","type":"uint64"}],"indexed":false,"internalType":"struct Assertion","name":"assertion","type":"tuple"},{"indexed":false,"internalType":"bytes32","name":"afterInboxBatchAcc","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"wasmModuleRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"inboxMaxCount","type":"uint256"}],"name":"NodeCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"nodeNum","type":"uint64"}],"name":"NodeRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"OwnerFunctionCalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"challengeIndex","type":"uint64"},{"indexed":false,"internalType":"address","name":"asserter","type":"address"},{"indexed":false,"internalType":"address","name":"challenger","type":"address"},{"indexed":false,"internalType":"uint64","name":"challengedNode","type":"uint64"}],"name":"RollupChallengeStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"machineHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"RollupInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"UpgradedSecondary","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"initialBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalBalance","type":"uint256"}],"name":"UserStakeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"initialBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalBalance","type":"uint256"}],"name":"UserWithdrawableFundsUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_stakerMap","outputs":[{"internalType":"uint256","name":"amountStaked","type":"uint256"},{"internalType":"uint64","name":"index","type":"uint64"},{"internalType":"uint64","name":"latestStakedNode","type":"uint64"},{"internalType":"uint64","name":"currentChallenge","type":"uint64"},{"internalType":"bool","name":"isStaked","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"amountStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridge","outputs":[{"internalType":"contract IBridge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"challengeManager","outputs":[{"internalType":"contract IChallengeManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"confirmPeriodBlocks","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"beforeState","type":"tuple"},{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"afterState","type":"tuple"},{"internalType":"uint64","name":"numBlocks","type":"uint64"}],"internalType":"struct Assertion","name":"assertion","type":"tuple"}],"name":"createNitroMigrationGenesis","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"currentChallenge","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extraChallengeTimeBlocks","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstUnresolvedNode","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"nodeNum","type":"uint64"},{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"internalType":"bytes32","name":"sendRoot","type":"bytes32"}],"name":"forceConfirmNode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"prevNode","type":"uint64"},{"internalType":"uint256","name":"prevNodeInboxMaxCount","type":"uint256"},{"components":[{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"beforeState","type":"tuple"},{"components":[{"components":[{"internalType":"bytes32[2]","name":"bytes32Vals","type":"bytes32[2]"},{"internalType":"uint64[2]","name":"u64Vals","type":"uint64[2]"}],"internalType":"struct GlobalState","name":"globalState","type":"tuple"},{"internalType":"enum MachineStatus","name":"machineStatus","type":"uint8"}],"internalType":"struct ExecutionState","name":"afterState","type":"tuple"},{"internalType":"uint64","name":"numBlocks","type":"uint64"}],"internalType":"struct Assertion","name":"assertion","type":"tuple"},{"internalType":"bytes32","name":"expectedNodeHash","type":"bytes32"}],"name":"forceCreateNode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"staker","type":"address[]"}],"name":"forceRefundStaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"stakerA","type":"address[]"},{"internalType":"address[]","name":"stakerB","type":"address[]"}],"name":"forceResolveChallenge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"nodeNum","type":"uint64"}],"name":"getNode","outputs":[{"components":[{"internalType":"bytes32","name":"stateHash","type":"bytes32"},{"internalType":"bytes32","name":"challengeHash","type":"bytes32"},{"internalType":"bytes32","name":"confirmData","type":"bytes32"},{"internalType":"uint64","name":"prevNum","type":"uint64"},{"internalType":"uint64","name":"deadlineBlock","type":"uint64"},{"internalType":"uint64","name":"noChildConfirmedBeforeBlock","type":"uint64"},{"internalType":"uint64","name":"stakerCount","type":"uint64"},{"internalType":"uint64","name":"childStakerCount","type":"uint64"},{"internalType":"uint64","name":"firstChildBlock","type":"uint64"},{"internalType":"uint64","name":"latestChildNumber","type":"uint64"},{"internalType":"uint64","name":"createdAtBlock","type":"uint64"},{"internalType":"bytes32","name":"nodeHash","type":"bytes32"}],"internalType":"struct Node","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"nodeNum","type":"uint64"}],"name":"getNodeCreationBlockForLogLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"getStaker","outputs":[{"components":[{"internalType":"uint256","name":"amountStaked","type":"uint256"},{"internalType":"uint64","name":"index","type":"uint64"},{"internalType":"uint64","name":"latestStakedNode","type":"uint64"},{"internalType":"uint64","name":"currentChallenge","type":"uint64"},{"internalType":"bool","name":"isStaked","type":"bool"}],"internalType":"struct IRollupCore.Staker","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"stakerNum","type":"uint64"}],"name":"getStakerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inbox","outputs":[{"internalType":"contract IInboxBase","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"confirmPeriodBlocks","type":"uint64"},{"internalType":"uint64","name":"extraChallengeTimeBlocks","type":"uint64"},{"internalType":"address","name":"stakeToken","type":"address"},{"internalType":"uint256","name":"baseStake","type":"uint256"},{"internalType":"bytes32","name":"wasmModuleRoot","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"loserStakeEscrow","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"chainConfig","type":"string"},{"internalType":"uint64","name":"genesisBlockNum","type":"uint64"},{"components":[{"internalType":"uint256","name":"delayBlocks","type":"uint256"},{"internalType":"uint256","name":"futureBlocks","type":"uint256"},{"internalType":"uint256","name":"delaySeconds","type":"uint256"},{"internalType":"uint256","name":"futureSeconds","type":"uint256"}],"internalType":"struct ISequencerInbox.MaxTimeVariation","name":"sequencerInboxMaxTimeVariation","type":"tuple"}],"internalType":"struct Config","name":"config","type":"tuple"},{"components":[{"internalType":"contract IBridge","name":"bridge","type":"address"},{"internalType":"contract ISequencerInbox","name":"sequencerInbox","type":"address"},{"internalType":"contract IInboxBase","name":"inbox","type":"address"},{"internalType":"contract IOutbox","name":"outbox","type":"address"},{"internalType":"contract IRollupEventInbox","name":"rollupEventInbox","type":"address"},{"internalType":"contract IChallengeManager","name":"challengeManager","type":"address"},{"internalType":"address","name":"rollupAdminLogic","type":"address"},{"internalType":"contract IRollupUser","name":"rollupUserLogic","type":"address"},{"internalType":"address","name":"validatorUtils","type":"address"},{"internalType":"address","name":"validatorWalletCreator","type":"address"}],"internalType":"struct ContractDependencies","name":"connectedContracts","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"isStaked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"isStakedOnLatestConfirmed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isValidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"isZombie","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastStakeBlock","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestConfirmed","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestNodeCreated","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"latestStakedNode","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"loserStakeEscrow","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumAssertionPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"nodeNum","type":"uint64"},{"internalType":"address","name":"staker","type":"address"}],"name":"nodeHasStaker","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"outbox","outputs":[{"internalType":"contract IOutbox","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_outbox","type":"address"}],"name":"removeOldOutbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollupDeploymentBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rollupEventInbox","outputs":[{"internalType":"contract IRollupEventInbox","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sequencerInbox","outputs":[{"internalType":"contract ISequencerInbox","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBaseStake","type":"uint256"}],"name":"setBaseStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"newConfirmPeriod","type":"uint64"}],"name":"setConfirmPeriodBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_inbox","type":"address"},{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setDelayedInbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"newExtraTimeBlocks","type":"uint64"}],"name":"setExtraChallengeTimeBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IInboxBase","name":"newInbox","type":"address"}],"name":"setInbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newLoserStakerEscrow","type":"address"}],"name":"setLoserStakeEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPeriod","type":"uint256"}],"name":"setMinimumAssertionPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOutbox","name":"_outbox","type":"address"}],"name":"setOutbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sequencerInbox","type":"address"}],"name":"setSequencerInbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newStakeToken","type":"address"}],"name":"setStakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_validator","type":"address[]"},{"internalType":"bool[]","name":"_val","type":"bool[]"}],"name":"setValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_validatorWhitelistDisabled","type":"bool"}],"name":"setValidatorWhitelistDisabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"newWasmModuleRoot","type":"bytes32"}],"name":"setWasmModuleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakerCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWithdrawableFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"beacon","type":"address"},{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeBeacon","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeSecondaryTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeSecondaryToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"validatorUtils","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"validatorWalletCreator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"validatorWhitelistDisabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wasmModuleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"withdrawableFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"zombieNum","type":"uint256"}],"name":"zombieAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"zombieCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"zombieNum","type":"uint256"}],"name":"zombieLatestStakedNode","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c0604052620000196200003660201b62002ca61760201c565b15156080523060a0523480156200002f57600080fd5b5062000111565b60408051600481526024810182526020810180516001600160e01b03166302881c7960e11b179052905160009182918291606491620000769190620000d3565b600060405180830381855afa9150503d8060008114620000b3576040519150601f19603f3d011682016040523d82523d6000602084013e620000b8565b606091505b5091509150818015620000cc575080516020145b9250505090565b6000825160005b81811015620000f65760208186018101518583015201620000da565b8181111562000106576000828501525b509190910192915050565b60805160a051615aa46200018b60003960008181611071015281816110b10152818161115701528181611197015281816119b4015281816119f401528181611b9701528181611bd701528181611cc90152818161259101526125d1015260008181612ab7015281816131e001526145200152615aa46000f3fe6080604052600436106103905760003560e01c80637ba9534a116101de578063ce11e6ab11610103578063ef40a6701161009b578063ef40a67014610d08578063f065de3f14610d3e578063f33e1fac14610d5e578063f38c937914610d7e578063f63a434a14610d9e578063facd743b14610dbe578063fb0e722b14610dee578063fc8ffa0314610e0e578063ff204f3b14610e2e57600080fd5b8063ce11e6ab14610b79578063ce66d05c14610b99578063d01e660214610bb9578063d735e21d14610bd9578063dcd030aa14610bfe578063dff6978714610c1e578063e78cea9214610c33578063e8bd492214610c53578063ee35f32714610ce857600080fd5b8063948d658811610176578063948d6588146109815780639846129a146109a15780639a8a0592146109b4578063a23c44b1146109ca578063a2b4f1d814610ad9578063a3ffb77214610af9578063aa38a6e714610b19578063aa65af4814610b39578063bc45e0ae14610b5957600080fd5b80637ba9534a1461086f5780637c75c298146108845780638456cb59146108a4578063848bf918146108b95780638640ce5f146108d957806389384960146108fe5780638ee1a1261461091e57806391c657e81461093457806392c8134c1461095457600080fd5b806347fb24c5116102c45780636177fd181161025c5780636177fd181461071d57806363721d6b1461076057806365f7f80d1461077557806369fd251c146107935780636ddd3744146107dc57806371ef232c146107fc57806376e7e23b14610812578063771b2f97146108285780637b83a3fe1461084f57600080fd5b806347fb24c51461061d5780634f1ef2861461063d5780634f61f8501461065057806351ed6a301461067057806352d1902d1461069057806353b60c4a146106a5578063567ca41b146106c55780635c975abb146106e55780636136fe2e146106fd57600080fd5b80631b1689e9116103375780631b1689e9146104ac57806328ff127a146104d05780632e7acfa6146104f05780632f30cabd146105285780632f7968e81461055e5780633659cfe61461057e5780633e96576e1461059e57806345e38b64146105e7578063470dce4e146105fd57600080fd5b8063014cc92c14610395578063023a96fe146103cb5780630397d458146103eb578063046f7da21461040d57806306ae5851146104225780630d40a0fd1461044257806312ab3d3b1461046257806313af40351461048c575b600080fd5b3480156103a157600080fd5b50606f546103b5906001600160a01b031681565b6040516103c29190614dbd565b60405180910390f35b3480156103d757600080fd5b50606e546103b5906001600160a01b031681565b3480156103f757600080fd5b5061040b610406366004614de6565b610e4e565b005b34801561041957600080fd5b5061040b611020565b34801561042e57600080fd5b5061040b61043d366004614e03565b611044565b34801561044e57600080fd5b5061040b61045d366004614de6565b611066565b34801561046e57600080fd5b50607e5461047c9060ff1681565b60405190151581526020016103c2565b34801561049857600080fd5b5061040b6104a7366004614de6565b611126565b3480156104b857600080fd5b506104c2607d5481565b6040519081526020016103c2565b3480156104dc57600080fd5b5061040b6104eb366004614e1c565b61114c565b3480156104fc57600080fd5b50606554610510906001600160401b031681565b6040516001600160401b0390911681526020016103c2565b34801561053457600080fd5b506104c2610543366004614de6565b6001600160a01b03166000908152607b602052604090205490565b34801561056a57600080fd5b5061040b610579366004614e94565b61195d565b34801561058a57600080fd5b5061040b610599366004614de6565b6119a9565b3480156105aa57600080fd5b506105106105b9366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160401b90046001600160401b031690565b3480156105f357600080fd5b506104c260735481565b34801561060957600080fd5b5061040b610618366004614ee0565b611a66565b34801561062957600080fd5b5061040b610638366004614f35565b611b0a565b61040b61064b366004614fdc565b611b8c565b34801561065c57600080fd5b5061040b61066b366004614de6565b611c3d565b34801561067c57600080fd5b506072546103b5906001600160a01b031681565b34801561069c57600080fd5b506104c2611cbc565b3480156106b157600080fd5b5061040b6106c0366004614de6565b611d6a565b3480156106d157600080fd5b5061040b6106e0366004614de6565b611da2565b3480156106f157600080fd5b5060335460ff1661047c565b34801561070957600080fd5b5061040b610718366004615083565b611e6f565b34801561072957600080fd5b5061047c610738366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160c01b900460ff1690565b34801561076c57600080fd5b50607a546104c2565b34801561078157600080fd5b506075546001600160401b0316610510565b34801561079f57600080fd5b506105106107ae366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160801b90046001600160401b031690565b3480156107e857600080fd5b506103b56107f7366004615083565b611eb1565b34801561080857600080fd5b506104c2607c5481565b34801561081e57600080fd5b506104c260675481565b34801561083457600080fd5b5060655461051090600160401b90046001600160401b031681565b34801561085b57600080fd5b5061040b61086a36600461509e565b611eea565b34801561087b57600080fd5b506105106121ed565b34801561089057600080fd5b5061040b61089f366004615106565b612203565b3480156108b057600080fd5b5061040b612377565b3480156108c557600080fd5b5061040b6108d4366004615147565b61239b565b3480156108e557600080fd5b50607554600160c01b90046001600160401b0316610510565b34801561090a57600080fd5b5061040b610919366004614e03565b612417565b34801561092a57600080fd5b506104c260685481565b34801561094057600080fd5b5061047c61094f366004614de6565b612439565b34801561096057600080fd5b5061097461096f366004615083565b61249d565b6040516103c29190615175565b34801561098d57600080fd5b5061040b61099c366004614e03565b612564565b61040b6109af366004614fdc565b612586565b3480156109c057600080fd5b506104c260665481565b3480156109d657600080fd5b50610a846109e5366004614de6565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152506001600160a01b0316600090815260796020908152604091829020825160a081018452815481526001909101546001600160401b0380821693830193909352600160401b8104831693820193909352600160801b83049091166060820152600160c01b90910460ff161515608082015290565b6040516103c29190600060a0820190508251825260208301516001600160401b038082166020850152806040860151166040850152806060860151166060850152505060808301511515608083015292915050565b348015610ae557600080fd5b5061040b610af4366004615271565b612633565b348015610b0557600080fd5b5061040b610b1436600461528e565b61265e565b348015610b2557600080fd5b50606d546103b5906001600160a01b031681565b348015610b4557600080fd5b5061047c610b543660046152f9565b612752565b348015610b6557600080fd5b506070546103b5906001600160a01b031681565b348015610b8557600080fd5b50606b546103b5906001600160a01b031681565b348015610ba557600080fd5b5061040b610bb4366004615083565b612789565b348015610bc557600080fd5b506103b5610bd4366004614e03565b612814565b348015610be557600080fd5b50607554600160401b90046001600160401b0316610510565b348015610c0a57600080fd5b5061047c610c19366004614de6565b612829565b348015610c2a57600080fd5b50607854610510565b348015610c3f57600080fd5b50606a546103b5906001600160a01b031681565b348015610c5f57600080fd5b50610cb0610c6e366004614de6565b607960205260009081526040902080546001909101546001600160401b0380821691600160401b8104821691600160801b82041690600160c01b900460ff1685565b604080519586526001600160401b0394851660208701529284169285019290925290911660608301521515608082015260a0016103c2565b348015610cf457600080fd5b50606c546103b5906001600160a01b031681565b348015610d1457600080fd5b506104c2610d23366004614de6565b6001600160a01b031660009081526079602052604090205490565b348015610d4a57600080fd5b506071546103b5906001600160a01b031681565b348015610d6a57600080fd5b50610510610d79366004614e03565b61286c565b348015610d8a57600080fd5b5061040b610d9936600461528e565b6128a3565b348015610daa57600080fd5b506104c2610db9366004615083565b612ab3565b348015610dca57600080fd5b5061047c610dd9366004614de6565b60746020526000908152604090205460ff1681565b348015610dfa57600080fd5b506069546103b5906001600160a01b031681565b348015610e1a57600080fd5b5061040b610e29366004614de6565b612b7c565b348015610e3a57600080fd5b5061040b610e49366004614de6565b612c0e565b60335460ff16610e795760405162461bcd60e51b8152600401610e7090615315565b60405180910390fd5b6000806001600160a01b0316826001600160a01b0316141590506000306001600160a01b031663cd205fda6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ece57600080fd5b505afa158015610ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f069190615343565b905081151581151514610f535760405162461bcd60e51b81526020600482015260156024820152741393d7d554d15497d313d1d250d7d4d5541413d495605a1b6044820152606401610e70565b6078546001600160401b031615610fa05760405162461bcd60e51b81526020600482015260116024820152704e4f5f4143544956455f5354414b45525360781b6044820152606401610e70565b607c5415610fe65760405162461bcd60e51b81526020600482015260136024820152724e4f5f50454e44494e475f574954484452415760681b6044820152606401610e70565b607280546001600160a01b0319166001600160a01b038516179055604051600d90600080516020615a2883398151915290600090a2505050565b611028612d3e565b604051600490600080516020615a2883398151915290600090a2565b6067819055604051600c90600080516020615a2883398151915290600090a250565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156110af5760405162461bcd60e51b8152600401610e7090615360565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166110e1612da4565b6001600160a01b0316146111075760405162461bcd60e51b8152600401610e70906153ac565b6040805160008082526020820190925261112391839190612dc5565b50565b61112f81612f65565b604051600790600080516020615a2883398151915290600090a250565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156111955760405162461bcd60e51b8152600401610e7090615360565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166111c7612da4565b6001600160a01b0316146111ed5760405162461bcd60e51b8152600401610e70906153ac565b600054610100900460ff166112085760005460ff161561120c565b303b155b61126f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610e70565b600054610100900460ff16158015611291576000805461ffff19166101011790555b43607d556112a26020830183614de6565b606a80546001600160a01b0319166001600160a01b03929092169190911790556112d26040830160208401614de6565b606c80546001600160a01b0319166001600160a01b03929092169190911790556112ff6020830183614de6565b6001600160a01b03166347fb24c561131d6060850160408601614de6565b60016040518363ffffffff1660e01b815260040161133c9291906153f8565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b5061137c925050506020830183614de6565b6001600160a01b0316634f61f85061139a6040850160208601614de6565b6040518263ffffffff1660e01b81526004016113b69190614dbd565b600060405180830381600087803b1580156113d057600080fd5b505af11580156113e4573d6000803e3d6000fd5b506113f9925050506060830160408401614de6565b606980546001600160a01b0319166001600160a01b03929092169190911790556114296080830160608401614de6565b606b80546001600160a01b0319166001600160a01b03929092169190911790556114566020830183614de6565b6001600160a01b031663cee3d7286114746080850160608601614de6565b60016040518363ffffffff1660e01b81526004016114939291906153f8565b600060405180830381600087803b1580156114ad57600080fd5b505af11580156114c1573d6000803e3d6000fd5b506114d69250505060a0830160808401614de6565b606d80546001600160a01b0319166001600160a01b03929092169190911790556115036020830183614de6565b6001600160a01b03166347fb24c561152160a0850160808601614de6565b60016040518363ffffffff1660e01b81526004016115409291906153f8565b600060405180830381600087803b15801561155a57600080fd5b505af115801561156e573d6000803e3d6000fd5b506115839250505060a0830160808401614de6565b6001600160a01b031663cf8d56d660e08501356115a4610100870187615413565b6040518463ffffffff1660e01b81526004016115c293929190615459565b600060405180830381600087803b1580156115dc57600080fd5b505af11580156115f0573d6000803e3d6000fd5b50611605925050506040830160208401614de6565b60405163e0bc972960e01b815260006004820181905260c0602483015260c4820181905260016044830181905260648301829052608483019190915260a48201526001600160a01b03919091169063e0bc97299060e401600060405180830381600087803b15801561167657600080fd5b505af115801561168a573d6000803e3d6000fd5b506116a19250505061012083016101008401614de6565b606f80546001600160a01b0319166001600160a01b03929092169190911790556116d361014083016101208401614de6565b607080546001600160a01b0319166001600160a01b039290921691909117905561170360c0830160a08401614de6565b606e80546001600160a01b0319166001600160a01b0392909216919091179055600061172d612fb9565b90506117388161300c565b6117456020850185615083565b6065805467ffffffffffffffff19166001600160401b03929092169190911790556117766040850160208601615083565b606580546001600160401b0392909216600160401b0267ffffffffffffffff60401b1990921691909117905560e084013560665560608401356067556080840135606855604b6073556117c76132a4565b6001600160a01b03166117e060e0860160c08701614de6565b6001600160a01b0316141561182e5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa2a9a1a927abafa0a226a4a760611b6044820152606401610e70565b61183e60c0850160a08601614de6565b6001600160a01b031661185760e0860160c08701614de6565b6001600160a01b031614156118a55760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa2a9a1a927abafa7aba722a960611b6044820152606401610e70565b6118b560e0850160c08601614de6565b607180546001600160a01b0319166001600160a01b03929092169190911790556118e56060850160408601614de6565b607280546001600160a01b0319166001600160a01b0392909216919091179055604080516080860135815260e086013560208201527ffc1b83c11d99d08a938e0b82a0bd45f822f71ff5abf23f999c93c4533d752464910160405180910390a1508015611958576000805461ff00191690555b505050565b60335460ff1661197f5760405162461bcd60e51b8152600401610e7090615315565b61198a8383836132cc565b604051601890600080516020615a2883398151915290600090a2505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156119f25760405162461bcd60e51b8152600401610e7090615360565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611a24612da4565b6001600160a01b031614611a4a5760405162461bcd60e51b8152600401610e70906153ac565b6040805160008082526020820190925261112391839190613426565b60335460ff16611a885760405162461bcd60e51b8152600401610e7090615315565b6075546001600160401b03858116911614611add5760405162461bcd60e51b815260206004820152601560248201527413d3931657d310551154d517d0d3d3919254935151605a1b6044820152606401610e70565b611ae9828585846135a0565b50604051601790600080516020615a2883398151915290600090a250505050565b606a546040516347fb24c560e01b81526001600160a01b03909116906347fb24c590611b3c90859085906004016153f8565b600060405180830381600087803b158015611b5657600080fd5b505af1158015611b6a573d6000803e3d6000fd5b505060405160029250600080516020615a288339815191529150600090a25050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415611bd55760405162461bcd60e51b8152600401610e7090615360565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611c07612da4565b6001600160a01b031614611c2d5760405162461bcd60e51b8152600401610e70906153ac565b611c3982826001613426565b5050565b606a546040516304f61f8560e41b81526001600160a01b0390911690634f61f85090611c6d908490600401614dbd565b600060405180830381600087803b158015611c8757600080fd5b505af1158015611c9b573d6000803e3d6000fd5b5050604051601b9250600080516020615a288339815191529150600090a250565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611d575760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610e70565b50600080516020615a0883398151915290565b606980546001600160a01b0319166001600160a01b038316179055604051601c90600080516020615a2883398151915290600090a250565b606b546001600160a01b0382811691161415611ded5760405162461bcd60e51b815260206004820152600a602482015269086aaa4be9eaaa8849eb60b31b6044820152606401610e70565b606a546040516319dc7ae560e31b81526001600160a01b039091169063cee3d72890611e209084906000906004016153f8565b600060405180830381600087803b158015611e3a57600080fd5b505af1158015611e4e573d6000803e3d6000fd5b505060405160019250600080516020615a288339815191529150600090a250565b6065805467ffffffffffffffff60401b1916600160401b6001600160401b03841602179055604051600a90600080516020615a2883398151915290600090a250565b60006078826001600160401b031681548110611ecf57611ecf61548f565b6000918252602090912001546001600160a01b031692915050565b60335460ff16611f0c5760405162461bcd60e51b8152600401610e7090615315565b60006001611f186121ed565b6001600160401b031615611f685760405162461bcd60e51b81526020600482015260176024820152761393d397d1d1539154d254d7d393d11154d7d1561254d5604a1b6044820152606401610e70565b611f7183613bb4565b611fb05760405162461bcd60e51b815260206004820152601060248201526f4e4f545f454d5054595f4245464f524560801b6044820152606401610e70565b6001611fc260a08501608086016154ca565b6003811115611fd357611fd36154a5565b146120205760405162461bcd60e51b815260206004820152601b60248201527f4245464f52455f4d414348494e455f4e4f545f46494e495348454400000000006044820152606401610e70565b60c083013582146120675760405162461bcd60e51b81526020600482015260116024820152701393d517d6915493d7d4d153911493d3d5607a1b6044820152606401610e70565b6001600160401b038116612082610100850160e08601615083565b6001600160401b0316146120cb5760405162461bcd60e51b815260206004820152601060248201526f494e424f585f4e4f545f41545f4f4e4560801b6044820152606401610e70565b6120dd61012084016101008501615083565b6001600160401b0316156121335760405162461bcd60e51b815260206004820152601c60248201527f504f534954494f4e5f494e5f4d4553534147455f4e4f545f5a45524f000000006044820152606401610e70565b6001612147610140850161012086016154ca565b6003811115612158576121586154a5565b146121a55760405162461bcd60e51b815260206004820152601a60248201527f41465445525f4d414348494e455f4e4f545f46494e49534845440000000000006044820152606401610e70565b60a08301356121c08460006001600160401b038516816135a0565b506121cd600182856132cc565b604051601d90600080516020615a2883398151915290600090a250505050565b607554600160801b90046001600160401b031690565b60335460ff166122255760405162461bcd60e51b8152600401610e7090615315565b806122425760405162461bcd60e51b8152600401610e70906154e5565b60005b818110156123585760006079818585858181106122645761226461548f565b90506020020160208101906122799190614de6565b6001600160a01b03168152602081019190915260400160002060010154600160801b90046001600160401b0316146122e55760405162461bcd60e51b815260206004820152600f60248201526e14d51052d15497d25397d0d2105313608a1b6044820152606401610e70565b6123168383838181106122fa576122fa61548f565b905060200201602081019061230f9190614de6565b6000613c10565b5061234683838381811061232c5761232c61548f565b90506020020160208101906123419190614de6565b613cd5565b8061235081615520565b915050612245565b50604051601690600080516020615a2883398151915290600090a25050565b61237f613d7b565b604051600390600080516020615a2883398151915290600090a2565b604051631b2ce7f360e11b81526001600160a01b03831690633659cfe6906123c7908490600401614dbd565b600060405180830381600087803b1580156123e157600080fd5b505af11580156123f5573d6000803e3d6000fd5b505060405160149250600080516020615a288339815191529150600090a25050565b6068819055604051601a90600080516020615a2883398151915290600090a250565b6000805b607a5481101561249457607a818154811061245a5761245a61548f565b6000918252602090912001546001600160a01b03848116911614156124825750600192915050565b8061248c81615520565b91505061243d565b50600092915050565b6124a5614c98565b6001600160401b03821660009081526076602052604090206040805161018081018252825481526001830154602082015260028301549181019190915260038201546001600160401b038082166060840152600160401b80830482166080850152600160801b808404831660a0860152600160c01b93849004831660c0860152600486015480841660e0870152918204831661010086015281048216610120850152919091041661014082015260059091015461016082015292915050565b6073819055604051600890600080516020615a2883398151915290600090a250565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156125cf5760405162461bcd60e51b8152600401610e7090615360565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612601612da4565b6001600160a01b0316146126275760405162461bcd60e51b8152600401610e70906153ac565b611c3982826001612dc5565b607e805460ff1916821515179055604051601e90600080516020615a2883398151915290600090a250565b8261267b5760405162461bcd60e51b8152600401610e70906154e5565b82811461269a5760405162461bcd60e51b8152600401610e709061553b565b60005b83811015612731578282828181106126b7576126b761548f565b90506020020160208101906126cc9190615271565b607460008787858181106126e2576126e261548f565b90506020020160208101906126f79190614de6565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558061272981615520565b91505061269d565b50604051600690600080516020615a2883398151915290600090a250505050565b6001600160401b03821660009081526077602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b6000816001600160401b0316116127db5760405162461bcd60e51b81526020600482015260166024820152751253959053125117d0d3d39192549357d411549253d160521b6044820152606401610e70565b6065805467ffffffffffffffff19166001600160401b038316179055604051600990600080516020615a2883398151915290600090a250565b6000607a8281548110611ecf57611ecf61548f565b6001600160a01b038116600090815260796020526040812060010154600160c01b900460ff1680156127835750607554612783906001600160401b031683612752565b6000607a82815481106128815761288161548f565b600091825260209091200154600160a01b90046001600160401b031692915050565b60335460ff166128c55760405162461bcd60e51b8152600401610e7090615315565b826128e25760405162461bcd60e51b8152600401610e70906154e5565b8281146129015760405162461bcd60e51b8152600401610e709061553b565b60005b83811015612a925760006129648686848181106129235761292361548f565b90506020020160208101906129389190614de6565b85858581811061294a5761294a61548f565b905060200201602081019061295f9190614de6565b613df6565b90506001600160401b0381166129ab5760405162461bcd60e51b815260206004820152600c60248201526b1393d517d25397d0d210531360a21b6044820152606401610e70565b612a038686848181106129c0576129c061548f565b90506020020160208101906129d59190614de6565b6001600160a01b03166000908152607960205260409020600101805467ffffffffffffffff60801b19169055565b612a188484848181106129c0576129c061548f565b606e546040516356e9df9760e01b81526001600160401b03831660048201526001600160a01b03909116906356e9df9790602401600060405180830381600087803b158015612a6657600080fd5b505af1158015612a7a573d6000803e3d6000fd5b50505050508080612a8a90615520565b915050612904565b50604051601590600080516020615a2883398151915290600090a250505050565b60007f000000000000000000000000000000000000000000000000000000000000000015612b11576001600160401b0382166000908152607f6020526040902054806127835760405162461bcd60e51b8152600401610e7090615561565b6001600160401b03821660009081526076602052604081206003810154909150600160401b90046001600160401b0316612b5d5760405162461bcd60e51b8152600401610e7090615561565b60040154600160c01b90046001600160401b031692915050565b919050565b612b846132a4565b6001600160a01b0316816001600160a01b03161415612bd65760405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f455343524f5760901b6044820152606401610e70565b607180546001600160a01b0319166001600160a01b038316179055604051601990600080516020615a2883398151915290600090a250565b606b80546001600160a01b0319166001600160a01b0383811691909117909155606a546040516319dc7ae560e31b815291169063cee3d72890612c589084906001906004016153f8565b600060405180830381600087803b158015612c7257600080fd5b505af1158015612c86573d6000803e3d6000fd5b505060405160009250600080516020615a2883398151915291508290a250565b60408051600481526024810182526020810180516001600160e01b03166302881c7960e11b179052905160009182918291606491612ce491906155ae565b600060405180830381855afa9150503d8060008114612d1f576040519150601f19603f3d011682016040523d82523d6000602084013e612d24565b606091505b5091509150818015612d37575080516020145b9250505090565b60335460ff16612d605760405162461bcd60e51b8152600401610e7090615315565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612d9a9190614dbd565b60405180910390a1565b6000600080516020615a088339815191525b546001600160a01b0316919050565b7f49bd798cd84788856140a4cd5030756b4d08a9e4d55db725ec195f232d262a895460ff1615612df85761195883613ec4565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b158015612e3157600080fd5b505afa925050508015612e61575060408051601f3d908101601f19168201909252612e5e918101906155ca565b60015b612ece5760405162461bcd60e51b815260206004820152603860248201527f45524331393637557067726164653a206e6577207365636f6e6461727920696d604482015277706c656d656e746174696f6e206973206e6f74205555505360401b6064820152608401610e70565b7f2b1dbce74324248c222f0ec2d5ed7bd323cfc425b336f0253c5ccfda7265546d8114612f595760405162461bcd60e51b815260206004820152603360248201527f45524331393637557067726164653a20756e737570706f72746564207365636f6044820152721b99185c9e481c1c9bde1a58589b1955555251606a1b6064820152608401610e70565b50611958838383613f7f565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f612f8e6132a4565b604080516001600160a01b03928316815291841660208301520160405180910390a161112381613faa565b612fc1614c98565b612fc9614cfc565b6000612ffb604051806040016040528084815260200160016003811115612ff257612ff26154a5565b90526001614036565b9050612d378160008080438161407b565b6130146140cf565b60008080526076602090815282517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a181958558201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a1819595560408201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195a5560608201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195b8054608085015160a086015160c08701516001600160401b039586166001600160801b031994851617600160401b9387168402176001600160801b03908116600160801b93881684026001600160c01b0390811691909117600160c01b93891684021790965560e08901517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195c80546101008c01516101208d01516101408e0151948c169290991691909117908a169096029590951790911694871690920290941692909217919093169091021790556101608201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195d556131b89060016155e3565b607560086101000a8154816001600160401b0302191690836001600160401b031602179055507f0000000000000000000000000000000000000000000000000000000000000000156111235760646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561323e57600080fd5b505afa158015613252573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327691906155ca565b60008052607f6020527f18b3a2798575d3a428c1f52e616a74b071539854e037e7d7c535365d474f40335550565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103612db6565b6001600160401b03831660009081526076602052604090206132ee8383614100565b81600201541461332f5760405162461bcd60e51b815260206004820152600c60248201526b434f4e4649524d5f4441544160a01b6044820152606401610e70565b606b54604051630502677360e51b815260048101849052602481018590526001600160a01b039091169063a04cee6090604401600060405180830381600087803b15801561337c57600080fd5b505af1158015613390573d6000803e3d6000fd5b50506075805467ffffffffffffffff19166001600160401b038816179055506133bc90508460016155e3565b6075805467ffffffffffffffff60401b1916600160401b6001600160401b03938416021790556040805185815260208101859052918616917f22ef0479a7ff660660d1c2fe35f1b632cf31675c2d9378db8cec95b00d8ffa3c91015b60405180910390a250505050565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613459576119588361411c565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561349257600080fd5b505afa9250505080156134c2575060408051601f3d908101601f191682019092526134bf918101906155ca565b60015b6135255760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610e70565b600080516020615a0883398151915281146135945760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610e70565b5061195883838361419e565b600060016135b6610140870161012088016154ca565b60038111156135c7576135c76154a5565b14806135f5575060026135e2610140870161012088016154ca565b60038111156135f3576135f36154a5565b145b6136345760405162461bcd60e51b815260206004820152601060248201526f4241445f41465445525f53544154555360801b6044820152606401610e70565b61363c614d21565b6136458561249d565b6060820152606a54604080516221048360e21b815290516001600160a01b03909216916284120c91600480820192602092909190829003018186803b15801561368d57600080fd5b505afa1580156136a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c591906155ca565b81526060810151516136d787866141a7565b146137165760405162461bcd60e51b815260206004820152600f60248201526e0a0a48aacbea6a882a88abe9082a69608b1b6044820152606401610e70565b600061373261372d36899003890160a08a016156d0565b6141e3565b9050600061374861372d368a90038a018a6156d0565b9050806001600160401b0316826001600160401b0316101561379e5760405162461bcd60e51b815260206004820152600f60248201526e494e424f585f4241434b574152445360881b6044820152606401610e70565b806001600160401b0316826001600160401b03161415613844576137cf6137ca368a90038a018a6156d0565b6141f8565b6001600160401b03166137ed6137ca368b90038b0160a08c016156d0565b6001600160401b031610156138445760405162461bcd60e51b815260206004820152601a60248201527f494e424f585f504f535f494e5f4d53475f4241434b57415244530000000000006044820152606401610e70565b60026138586101408a016101208b016154ca565b6003811115613869576138696154a5565b1480613892575060006138876137ca368b90038b0160a08c016156d0565b6001600160401b0316115b156138a557816138a1816156ec565b9250505b82516001600160401b03831611156138f05760405162461bcd60e51b815260206004820152600e60248201526d12539093d617d41054d517d1539160921b6044820152606401610e70565b6001600160401b0382161561399857606a546001600160a01b03166316bf557961391b600185615713565b6040516001600160e01b031960e084901b1681526001600160401b03909116600482015260240160206040518083038186803b15801561395a57600080fd5b505afa15801561396e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061399291906155ca565b60e08401525b506139b290506139ad3688900388018861577a565b614207565b60408201526065546139cd906001600160401b0316436155e3565b6001600160401b0390811660c0830152606082015161012001511615801560a0830152613a2357606081015161012001516001600160401b03166000908152607660205260409020600501546080820152613a33565b6060810151610160015160808201525b613a528160a00151826080015183604001518460e001516068546142a6565b915082821480613a60575082155b613aa35760405162461bcd60e51b81526020600482015260146024820152730aa9c8ab0a08a86a88a88be9c9e888abe9082a6960631b6044820152606401610e70565b613aeb613ab78760a00183600001516141a7565b613ac8836040015143606854614313565b613adf613ada368b90038b018b61577a565b614352565b888560c001518761407b565b60208201526000613afa6121ed565b613b059060016155e3565b90506000613b27876001600160401b0316600090815260766020526040902090565b9050613b33818361437c565b613b4083602001516143ed565b50508181606001516101600151613b556121ed565b6001600160401b03167f4f4caa9e67fb994e349dd35d1ad0ce23053d4323f83ce11dc817b5435031d09684604001518a8660e001516068548860000151604051613ba3959493929190615864565b60405180910390a450949350505050565b60008135158015613bc757506020820135155b8015613be95750613bde6060830160408401615083565b6001600160401b0316155b80156127835750613c006080830160608401615083565b6001600160401b03161592915050565b6001600160a01b0382166000908152607960205260408120805480841115613c6d5760405162461bcd60e51b815260206004820152601060248201526f544f4f5f4c4954544c455f5354414b4560801b6044820152606401610e70565b6000613c7985836158c4565b8584559050613c8886826145db565b60408051838152602081018790526001600160a01b038816917febd093d389ab57f3566918d2c379a2b4d9539e8eb95efad9d5e465457833fde6910160405180910390a295945050505050565b6001600160a01b03808216600081815260796020908152604080832081518083019092529381526001808501546001600160401b03600160401b9091048116938301938452607a8054928301815590945290517ff0440771a29e57e18c66727944770b82cc77924aef333c927ce6bdd2cdb3ae0390910180549251909316600160a01b026001600160e01b031990921694169390931792909217909155611c3982614677565b60335460ff1615613dc15760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610e70565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d8d3390565b6001600160a01b03828116600090815260796020526040808220928416825281206001830154919291600160801b90046001600160401b031680613e665760405162461bcd60e51b81526020600482015260076024820152661393d7d0d2105360ca1b6044820152606401610e70565b60018201546001600160401b03828116600160801b9092041614613ebb5760405162461bcd60e51b815260206004820152600c60248201526b1112519197d25397d0d2105360a21b6044820152606401610e70565b95945050505050565b6001600160a01b0381163b613f3b5760405162461bcd60e51b815260206004820152603760248201527f455243313936373a206e6577207365636f6e6461727920696d706c656d656e74604482015276185d1a5bdb881a5cc81b9bdd08184818dbdb9d1c9858dd604a1b6064820152608401610e70565b807f2b1dbce74324248c222f0ec2d5ed7bd323cfc425b336f0253c5ccfda7265546d5b80546001600160a01b0319166001600160a01b039290921691909117905550565b613f888361483a565b600082511180613f955750805b1561195857613fa4838361487a565b50505050565b6001600160a01b03811661400f5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610e70565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103613f5e565b6000614045836000015161489f565b82846020015160405160200161405d939291906158db565b60405160208183030381529060405280519060200120905092915050565b614083614c98565b61408b614c98565b96875250602086019490945260408501929092526001600160401b0390811660608501529081166080840181905260a0840152431661014083015261016082015290565b600054610100900460ff166140f65760405162461bcd60e51b8152600401610e7090615919565b6140fe614913565b565b604080516020810184905290810182905260009060600161405d565b6001600160a01b0381163b6141895760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610e70565b80600080516020615a08833981519152613f5e565b613f8883614946565b60006141c06141bb368590038501856156d0565b61489f565b826141d160a08601608087016154ca565b60405160200161405d939291906158db565b6020810151600090815b602002015192915050565b602081015160009060016141ed565b6000614211614d72565b8251602001518190600381111561422a5761422a6154a5565b9081600381111561423d5761423d6154a5565b90525060208381015181015190820190600381111561425e5761425e6154a5565b90816003811115614271576142716154a5565b90525061427c614d90565b83515181526020808501515190820152604084015161429e9083908390614986565b949350505050565b600080866142b55760006142b8565b60015b6040516001600160f81b031960f883901b1660208201526021810188905260418101879052606181018690526081810185905290915060a1016040516020818303038152906040528051906020012091505095945050505050565b6040805160208101859052908101839052606081018290526000906080015b6040516020818303038152906040528051906020012090505b9392505050565b6000612783614368836020015160000151614a30565b60208401515161437790614a3b565b614100565b6004820154600160401b90046001600160401b03166143bd5760048201805467ffffffffffffffff60401b1916600160401b436001600160401b0316021790555b600490910180546001600160401b03909216600160801b0267ffffffffffffffff60801b19909216919091179055565b60758054600160801b90046001600160401b031690601061440d836156ec565b825461010092830a6001600160401b03818102199092169282160291909117909255607554600160801b908190048316600090815260766020908152604091829020875181559087015160018201559086015160028201556060860151600382018054608089015160a08a015160c08b01519489166001600160801b031993841617600160401b928a168302176001600160801b03908116918a1688026001600160c01b0390811692909217600160c01b968b1687021790945560e08b0151600487018054998d01516101208e01516101408f0151938d169b9096169a909a17998b16909302989098179093169188169095029091161793909416909302919091179055610160830151600590910155507f0000000000000000000000000000000000000000000000000000000000000000156111235760646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561457e57600080fd5b505afa158015614592573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145b691906155ca565b607554600160801b90046001600160401b03166000908152607f602052604090205550565b6001600160a01b0382166000908152607b6020526040812054906145ff8383615964565b6001600160a01b0385166000908152607b60205260408120829055607c80549293508592909190614631908490615964565b909155505060408051838152602081018390526001600160a01b038616917fa740af14c56e4e04a617b1de1eb20de73270decbaaead14f142aabf3038e5ae29101613418565b6001600160a01b03811660009081526079602052604090206001810154600160c01b900460ff166146d75760405162461bcd60e51b815260206004820152600a6024820152691393d517d4d51052d15160b21b6044820152606401610e70565b600180820154607880546001600160401b039092169290916146f991906158c4565b815481106147095761470961548f565b600091825260209091200154607880546001600160a01b03909216916001600160401b03841690811061473e5761473e61548f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555080607960006078846001600160401b03168154811061478d5761478d61548f565b6000918252602080832091909101546001600160a01b031683528201929092526040019020600101805467ffffffffffffffff19166001600160401b039290921691909117905560788054806147e5576147e561597c565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b03949094168152607990935250506040812090815560010180546001600160c81b0319169055565b61484381613ec4565b6040516001600160a01b038216907ff7eed2a7fabbf1bec8d55ed5e785cc76622376dde5df4ff15470551e030b813490600090a250565b606061434b8383604051806060016040528060278152602001615a4860279139614a47565b8051805160209182015192820151805190830151604080516c23b637b130b61039ba30ba329d60991b81870152602d810194909452604d8401959095526001600160c01b031960c092831b8116606d850152911b1660758201528251808203605d018152607d909101909252815191012090565b600054610100900460ff1661493a5760405162461bcd60e51b8152600401610e7090615919565b6033805460ff19169055565b61494f8161411c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b604080516002808252606082018352600092839291906020830190803683370190505085519091506149c8906149c38660005b602002015161489f565b614b24565b816000815181106149db576149db61548f565b60209081029190910101526149fc85600160200201516149c38660016149b9565b81600181518110614a0f57614a0f61548f565b602002602001018181525050613ebb6000846001600160401b031683614c48565b8051600090816141ed565b805160009060016141ed565b60606001600160a01b0384163b614aaf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610e70565b600080856001600160a01b031685604051614aca91906155ae565b600060405180830381855af49150503d8060008114614b05576040519150601f19603f3d011682016040523d82523d6000602084013e614b0a565b606091505b5091509150614b1a828286614c5f565b9695505050505050565b60006001836003811115614b3a57614b3a6154a5565b1415614b80576040516b213637b1b59039ba30ba329d60a11b6020820152602c8101839052604c015b604051602081830303815290604052805190602001209050612783565b6002836003811115614b9457614b946154a5565b1415614bca5760405174213637b1b59039ba30ba32961032b93937b932b21d60591b602082015260358101839052605501614b63565b6003836003811115614bde57614bde6154a5565b1415614c0d5760405174213637b1b59039ba30ba3296103a37b7903330b91d60591b6020820152603501614b63565b60405162461bcd60e51b815260206004820152601060248201526f4241445f424c4f434b5f53544154555360801b6044820152606401610e70565b600083838360405160200161433293929190615992565b60608315614c6e57508161434b565b825115614c7e5782518084602001fd5b8160405162461bcd60e51b8152600401610e7091906159d4565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b6040518060400160405280614d0f614d72565b8152602001614d1c614d72565b905290565b60405180610100016040528060008152602001614d3c614c98565b815260006020820152604001614d50614c98565b8152600060208201819052604082018190526060820181905260809091015290565b60405180604001604052806002906020820280368337509192915050565b60405180604001604052806002905b614da7614cfc565b815260200190600190039081614d9f5790505090565b6001600160a01b0391909116815260200190565b6001600160a01b038116811461112357600080fd5b600060208284031215614df857600080fd5b813561434b81614dd1565b600060208284031215614e1557600080fd5b5035919050565b600080828403610160811215614e3157600080fd5b83356001600160401b03811115614e4757600080fd5b84016101c08187031215614e5a57600080fd5b9250610140601f1982011215614e6f57600080fd5b506020830190509250929050565b80356001600160401b0381168114612b7757600080fd5b600080600060608486031215614ea957600080fd5b614eb284614e7d565b95602085013595506040909401359392505050565b60006101608284031215614eda57600080fd5b50919050565b6000806000806101c08587031215614ef757600080fd5b614f0085614e7d565b935060208501359250614f168660408701614ec7565b939692955092936101a00135925050565b801515811461112357600080fd5b60008060408385031215614f4857600080fd5b8235614f5381614dd1565b91506020830135614f6381614f27565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715614fa657614fa6614f6e565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614fd457614fd4614f6e565b604052919050565b60008060408385031215614fef57600080fd5b8235614ffa81614dd1565b91506020838101356001600160401b038082111561501757600080fd5b818601915086601f83011261502b57600080fd5b81358181111561503d5761503d614f6e565b61504f601f8201601f19168501614fac565b9150808252878482850101111561506557600080fd5b80848401858401376000848284010152508093505050509250929050565b60006020828403121561509557600080fd5b61434b82614e7d565b600061016082840312156150b157600080fd5b61434b8383614ec7565b60008083601f8401126150cd57600080fd5b5081356001600160401b038111156150e457600080fd5b6020830191508360208260051b85010111156150ff57600080fd5b9250929050565b6000806020838503121561511957600080fd5b82356001600160401b0381111561512f57600080fd5b61513b858286016150bb565b90969095509350505050565b6000806040838503121561515a57600080fd5b823561516581614dd1565b91506020830135614f6381614dd1565b60006101808201905082518252602083015160208301526040830151604083015260608301516151b060608401826001600160401b03169052565b5060808301516151cb60808401826001600160401b03169052565b5060a08301516151e660a08401826001600160401b03169052565b5060c083015161520160c08401826001600160401b03169052565b5060e083015161521c60e08401826001600160401b03169052565b50610100838101516001600160401b038116848301525050610120838101516001600160401b038116848301525050610140838101516001600160401b03811684830152505061016092830151919092015290565b60006020828403121561528357600080fd5b813561434b81614f27565b600080600080604085870312156152a457600080fd5b84356001600160401b03808211156152bb57600080fd5b6152c7888389016150bb565b909650945060208701359150808211156152e057600080fd5b506152ed878288016150bb565b95989497509550505050565b6000806040838503121561530c57600080fd5b61516583614e7d565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60006020828403121561535557600080fd5b815161434b81614f27565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6001600160a01b039290921682521515602082015260400190565b6000808335601e1984360301811261542a57600080fd5b8301803591506001600160401b0382111561544457600080fd5b6020019150368190038213156150ff57600080fd5b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b803560048110612b7757600080fd5b6000602082840312156154dc57600080fd5b61434b826154bb565b6020808252600b908201526a454d5054595f415252415960a81b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006000198214156155345761553461550a565b5060010190565b6020808252600c908201526b0aea49e9c8ebe988a9c8ea8960a31b604082015260600190565b6020808252600790820152664e4f5f4e4f444560c81b604082015260600190565b60005b8381101561559d578181015183820152602001615585565b83811115613fa45750506000910152565b600082516155c0818460208701615582565b9190910192915050565b6000602082840312156155dc57600080fd5b5051919050565b60006001600160401b038083168185168083038211156156055761560561550a565b01949350505050565b60006080828403121561562057600080fd5b615628614f84565b905082601f83011261563957600080fd5b615641614f84565b80604084018581111561565357600080fd5b845b8181101561566d578035845260209384019301615655565b5081845285605f86011261568057600080fd5b615688614f84565b9250829150608085018681111561569e57600080fd5b808210156156c2576156af82614e7d565b845260208401935060208201915061569e565b505060208301525092915050565b6000608082840312156156e257600080fd5b61434b838361560e565b60006001600160401b03808316818114156157095761570961550a565b6001019392505050565b60006001600160401b03838116908316818110156157335761573361550a565b039392505050565b600060a0828403121561574d57600080fd5b615755614f84565b9050615761838361560e565b815261576f608083016154bb565b602082015292915050565b6000610160828403121561578d57600080fd5b604051606081018181106001600160401b03821117156157af576157af614f6e565b6040526157bc848461573b565b81526157cb8460a0850161573b565b60208201526157dd6101408401614e7d565b60408201529392505050565b604081833760006040838101828152908301915b600281101561582c576001600160401b0361581784614e7d565b168252602092830192909101906001016157fd565b50505061583b608082016154bb565b6004811061585957634e487b7160e01b600052602160045260246000fd5b806080840152505050565b8581526101e0810161587960208301876157e9565b61588960c0830160a088016157e9565b6001600160401b0361589e6101408801614e7d565b1661016083015284610180830152836101a0830152826101c08301529695505050505050565b6000828210156158d6576158d661550a565b500390565b83815282602082015260006004831061590457634e487b7160e01b600052602160045260246000fd5b5060f89190911b604082015260410192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082198211156159775761597761550a565b500190565b634e487b7160e01b600052603160045260246000fd5b83815260006020848184015260408301845182860160005b828110156159c6578151845292840192908401906001016159aa565b509198975050505050505050565b60208152600082518060208401526159f3816040850160208701615582565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbcea8787f128d10b2cc0317b0c3960f9ad447f7f6c1ed189db1083ccffd20f456e416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b130a4a88b5d102c2303c4905ebfd7378faeb598be3e7fecc4b23b4614f647a664736f6c63430008090033
Deployed Bytecode
0x6080604052600436106103905760003560e01c80637ba9534a116101de578063ce11e6ab11610103578063ef40a6701161009b578063ef40a67014610d08578063f065de3f14610d3e578063f33e1fac14610d5e578063f38c937914610d7e578063f63a434a14610d9e578063facd743b14610dbe578063fb0e722b14610dee578063fc8ffa0314610e0e578063ff204f3b14610e2e57600080fd5b8063ce11e6ab14610b79578063ce66d05c14610b99578063d01e660214610bb9578063d735e21d14610bd9578063dcd030aa14610bfe578063dff6978714610c1e578063e78cea9214610c33578063e8bd492214610c53578063ee35f32714610ce857600080fd5b8063948d658811610176578063948d6588146109815780639846129a146109a15780639a8a0592146109b4578063a23c44b1146109ca578063a2b4f1d814610ad9578063a3ffb77214610af9578063aa38a6e714610b19578063aa65af4814610b39578063bc45e0ae14610b5957600080fd5b80637ba9534a1461086f5780637c75c298146108845780638456cb59146108a4578063848bf918146108b95780638640ce5f146108d957806389384960146108fe5780638ee1a1261461091e57806391c657e81461093457806392c8134c1461095457600080fd5b806347fb24c5116102c45780636177fd181161025c5780636177fd181461071d57806363721d6b1461076057806365f7f80d1461077557806369fd251c146107935780636ddd3744146107dc57806371ef232c146107fc57806376e7e23b14610812578063771b2f97146108285780637b83a3fe1461084f57600080fd5b806347fb24c51461061d5780634f1ef2861461063d5780634f61f8501461065057806351ed6a301461067057806352d1902d1461069057806353b60c4a146106a5578063567ca41b146106c55780635c975abb146106e55780636136fe2e146106fd57600080fd5b80631b1689e9116103375780631b1689e9146104ac57806328ff127a146104d05780632e7acfa6146104f05780632f30cabd146105285780632f7968e81461055e5780633659cfe61461057e5780633e96576e1461059e57806345e38b64146105e7578063470dce4e146105fd57600080fd5b8063014cc92c14610395578063023a96fe146103cb5780630397d458146103eb578063046f7da21461040d57806306ae5851146104225780630d40a0fd1461044257806312ab3d3b1461046257806313af40351461048c575b600080fd5b3480156103a157600080fd5b50606f546103b5906001600160a01b031681565b6040516103c29190614dbd565b60405180910390f35b3480156103d757600080fd5b50606e546103b5906001600160a01b031681565b3480156103f757600080fd5b5061040b610406366004614de6565b610e4e565b005b34801561041957600080fd5b5061040b611020565b34801561042e57600080fd5b5061040b61043d366004614e03565b611044565b34801561044e57600080fd5b5061040b61045d366004614de6565b611066565b34801561046e57600080fd5b50607e5461047c9060ff1681565b60405190151581526020016103c2565b34801561049857600080fd5b5061040b6104a7366004614de6565b611126565b3480156104b857600080fd5b506104c2607d5481565b6040519081526020016103c2565b3480156104dc57600080fd5b5061040b6104eb366004614e1c565b61114c565b3480156104fc57600080fd5b50606554610510906001600160401b031681565b6040516001600160401b0390911681526020016103c2565b34801561053457600080fd5b506104c2610543366004614de6565b6001600160a01b03166000908152607b602052604090205490565b34801561056a57600080fd5b5061040b610579366004614e94565b61195d565b34801561058a57600080fd5b5061040b610599366004614de6565b6119a9565b3480156105aa57600080fd5b506105106105b9366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160401b90046001600160401b031690565b3480156105f357600080fd5b506104c260735481565b34801561060957600080fd5b5061040b610618366004614ee0565b611a66565b34801561062957600080fd5b5061040b610638366004614f35565b611b0a565b61040b61064b366004614fdc565b611b8c565b34801561065c57600080fd5b5061040b61066b366004614de6565b611c3d565b34801561067c57600080fd5b506072546103b5906001600160a01b031681565b34801561069c57600080fd5b506104c2611cbc565b3480156106b157600080fd5b5061040b6106c0366004614de6565b611d6a565b3480156106d157600080fd5b5061040b6106e0366004614de6565b611da2565b3480156106f157600080fd5b5060335460ff1661047c565b34801561070957600080fd5b5061040b610718366004615083565b611e6f565b34801561072957600080fd5b5061047c610738366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160c01b900460ff1690565b34801561076c57600080fd5b50607a546104c2565b34801561078157600080fd5b506075546001600160401b0316610510565b34801561079f57600080fd5b506105106107ae366004614de6565b6001600160a01b0316600090815260796020526040902060010154600160801b90046001600160401b031690565b3480156107e857600080fd5b506103b56107f7366004615083565b611eb1565b34801561080857600080fd5b506104c2607c5481565b34801561081e57600080fd5b506104c260675481565b34801561083457600080fd5b5060655461051090600160401b90046001600160401b031681565b34801561085b57600080fd5b5061040b61086a36600461509e565b611eea565b34801561087b57600080fd5b506105106121ed565b34801561089057600080fd5b5061040b61089f366004615106565b612203565b3480156108b057600080fd5b5061040b612377565b3480156108c557600080fd5b5061040b6108d4366004615147565b61239b565b3480156108e557600080fd5b50607554600160c01b90046001600160401b0316610510565b34801561090a57600080fd5b5061040b610919366004614e03565b612417565b34801561092a57600080fd5b506104c260685481565b34801561094057600080fd5b5061047c61094f366004614de6565b612439565b34801561096057600080fd5b5061097461096f366004615083565b61249d565b6040516103c29190615175565b34801561098d57600080fd5b5061040b61099c366004614e03565b612564565b61040b6109af366004614fdc565b612586565b3480156109c057600080fd5b506104c260665481565b3480156109d657600080fd5b50610a846109e5366004614de6565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152506001600160a01b0316600090815260796020908152604091829020825160a081018452815481526001909101546001600160401b0380821693830193909352600160401b8104831693820193909352600160801b83049091166060820152600160c01b90910460ff161515608082015290565b6040516103c29190600060a0820190508251825260208301516001600160401b038082166020850152806040860151166040850152806060860151166060850152505060808301511515608083015292915050565b348015610ae557600080fd5b5061040b610af4366004615271565b612633565b348015610b0557600080fd5b5061040b610b1436600461528e565b61265e565b348015610b2557600080fd5b50606d546103b5906001600160a01b031681565b348015610b4557600080fd5b5061047c610b543660046152f9565b612752565b348015610b6557600080fd5b506070546103b5906001600160a01b031681565b348015610b8557600080fd5b50606b546103b5906001600160a01b031681565b348015610ba557600080fd5b5061040b610bb4366004615083565b612789565b348015610bc557600080fd5b506103b5610bd4366004614e03565b612814565b348015610be557600080fd5b50607554600160401b90046001600160401b0316610510565b348015610c0a57600080fd5b5061047c610c19366004614de6565b612829565b348015610c2a57600080fd5b50607854610510565b348015610c3f57600080fd5b50606a546103b5906001600160a01b031681565b348015610c5f57600080fd5b50610cb0610c6e366004614de6565b607960205260009081526040902080546001909101546001600160401b0380821691600160401b8104821691600160801b82041690600160c01b900460ff1685565b604080519586526001600160401b0394851660208701529284169285019290925290911660608301521515608082015260a0016103c2565b348015610cf457600080fd5b50606c546103b5906001600160a01b031681565b348015610d1457600080fd5b506104c2610d23366004614de6565b6001600160a01b031660009081526079602052604090205490565b348015610d4a57600080fd5b506071546103b5906001600160a01b031681565b348015610d6a57600080fd5b50610510610d79366004614e03565b61286c565b348015610d8a57600080fd5b5061040b610d9936600461528e565b6128a3565b348015610daa57600080fd5b506104c2610db9366004615083565b612ab3565b348015610dca57600080fd5b5061047c610dd9366004614de6565b60746020526000908152604090205460ff1681565b348015610dfa57600080fd5b506069546103b5906001600160a01b031681565b348015610e1a57600080fd5b5061040b610e29366004614de6565b612b7c565b348015610e3a57600080fd5b5061040b610e49366004614de6565b612c0e565b60335460ff16610e795760405162461bcd60e51b8152600401610e7090615315565b60405180910390fd5b6000806001600160a01b0316826001600160a01b0316141590506000306001600160a01b031663cd205fda6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ece57600080fd5b505afa158015610ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f069190615343565b905081151581151514610f535760405162461bcd60e51b81526020600482015260156024820152741393d7d554d15497d313d1d250d7d4d5541413d495605a1b6044820152606401610e70565b6078546001600160401b031615610fa05760405162461bcd60e51b81526020600482015260116024820152704e4f5f4143544956455f5354414b45525360781b6044820152606401610e70565b607c5415610fe65760405162461bcd60e51b81526020600482015260136024820152724e4f5f50454e44494e475f574954484452415760681b6044820152606401610e70565b607280546001600160a01b0319166001600160a01b038516179055604051600d90600080516020615a2883398151915290600090a2505050565b611028612d3e565b604051600490600080516020615a2883398151915290600090a2565b6067819055604051600c90600080516020615a2883398151915290600090a250565b306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a1614156110af5760405162461bcd60e51b8152600401610e7090615360565b7f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a6001600160a01b03166110e1612da4565b6001600160a01b0316146111075760405162461bcd60e51b8152600401610e70906153ac565b6040805160008082526020820190925261112391839190612dc5565b50565b61112f81612f65565b604051600790600080516020615a2883398151915290600090a250565b306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a1614156111955760405162461bcd60e51b8152600401610e7090615360565b7f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a6001600160a01b03166111c7612da4565b6001600160a01b0316146111ed5760405162461bcd60e51b8152600401610e70906153ac565b600054610100900460ff166112085760005460ff161561120c565b303b155b61126f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610e70565b600054610100900460ff16158015611291576000805461ffff19166101011790555b43607d556112a26020830183614de6565b606a80546001600160a01b0319166001600160a01b03929092169190911790556112d26040830160208401614de6565b606c80546001600160a01b0319166001600160a01b03929092169190911790556112ff6020830183614de6565b6001600160a01b03166347fb24c561131d6060850160408601614de6565b60016040518363ffffffff1660e01b815260040161133c9291906153f8565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b5061137c925050506020830183614de6565b6001600160a01b0316634f61f85061139a6040850160208601614de6565b6040518263ffffffff1660e01b81526004016113b69190614dbd565b600060405180830381600087803b1580156113d057600080fd5b505af11580156113e4573d6000803e3d6000fd5b506113f9925050506060830160408401614de6565b606980546001600160a01b0319166001600160a01b03929092169190911790556114296080830160608401614de6565b606b80546001600160a01b0319166001600160a01b03929092169190911790556114566020830183614de6565b6001600160a01b031663cee3d7286114746080850160608601614de6565b60016040518363ffffffff1660e01b81526004016114939291906153f8565b600060405180830381600087803b1580156114ad57600080fd5b505af11580156114c1573d6000803e3d6000fd5b506114d69250505060a0830160808401614de6565b606d80546001600160a01b0319166001600160a01b03929092169190911790556115036020830183614de6565b6001600160a01b03166347fb24c561152160a0850160808601614de6565b60016040518363ffffffff1660e01b81526004016115409291906153f8565b600060405180830381600087803b15801561155a57600080fd5b505af115801561156e573d6000803e3d6000fd5b506115839250505060a0830160808401614de6565b6001600160a01b031663cf8d56d660e08501356115a4610100870187615413565b6040518463ffffffff1660e01b81526004016115c293929190615459565b600060405180830381600087803b1580156115dc57600080fd5b505af11580156115f0573d6000803e3d6000fd5b50611605925050506040830160208401614de6565b60405163e0bc972960e01b815260006004820181905260c0602483015260c4820181905260016044830181905260648301829052608483019190915260a48201526001600160a01b03919091169063e0bc97299060e401600060405180830381600087803b15801561167657600080fd5b505af115801561168a573d6000803e3d6000fd5b506116a19250505061012083016101008401614de6565b606f80546001600160a01b0319166001600160a01b03929092169190911790556116d361014083016101208401614de6565b607080546001600160a01b0319166001600160a01b039290921691909117905561170360c0830160a08401614de6565b606e80546001600160a01b0319166001600160a01b0392909216919091179055600061172d612fb9565b90506117388161300c565b6117456020850185615083565b6065805467ffffffffffffffff19166001600160401b03929092169190911790556117766040850160208601615083565b606580546001600160401b0392909216600160401b0267ffffffffffffffff60401b1990921691909117905560e084013560665560608401356067556080840135606855604b6073556117c76132a4565b6001600160a01b03166117e060e0860160c08701614de6565b6001600160a01b0316141561182e5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa2a9a1a927abafa0a226a4a760611b6044820152606401610e70565b61183e60c0850160a08601614de6565b6001600160a01b031661185760e0860160c08701614de6565b6001600160a01b031614156118a55760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22fa2a9a1a927abafa7aba722a960611b6044820152606401610e70565b6118b560e0850160c08601614de6565b607180546001600160a01b0319166001600160a01b03929092169190911790556118e56060850160408601614de6565b607280546001600160a01b0319166001600160a01b0392909216919091179055604080516080860135815260e086013560208201527ffc1b83c11d99d08a938e0b82a0bd45f822f71ff5abf23f999c93c4533d752464910160405180910390a1508015611958576000805461ff00191690555b505050565b60335460ff1661197f5760405162461bcd60e51b8152600401610e7090615315565b61198a8383836132cc565b604051601890600080516020615a2883398151915290600090a2505050565b306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a1614156119f25760405162461bcd60e51b8152600401610e7090615360565b7f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a6001600160a01b0316611a24612da4565b6001600160a01b031614611a4a5760405162461bcd60e51b8152600401610e70906153ac565b6040805160008082526020820190925261112391839190613426565b60335460ff16611a885760405162461bcd60e51b8152600401610e7090615315565b6075546001600160401b03858116911614611add5760405162461bcd60e51b815260206004820152601560248201527413d3931657d310551154d517d0d3d3919254935151605a1b6044820152606401610e70565b611ae9828585846135a0565b50604051601790600080516020615a2883398151915290600090a250505050565b606a546040516347fb24c560e01b81526001600160a01b03909116906347fb24c590611b3c90859085906004016153f8565b600060405180830381600087803b158015611b5657600080fd5b505af1158015611b6a573d6000803e3d6000fd5b505060405160029250600080516020615a288339815191529150600090a25050565b306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a161415611bd55760405162461bcd60e51b8152600401610e7090615360565b7f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a6001600160a01b0316611c07612da4565b6001600160a01b031614611c2d5760405162461bcd60e51b8152600401610e70906153ac565b611c3982826001613426565b5050565b606a546040516304f61f8560e41b81526001600160a01b0390911690634f61f85090611c6d908490600401614dbd565b600060405180830381600087803b158015611c8757600080fd5b505af1158015611c9b573d6000803e3d6000fd5b5050604051601b9250600080516020615a288339815191529150600090a250565b6000306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a1614611d575760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610e70565b50600080516020615a0883398151915290565b606980546001600160a01b0319166001600160a01b038316179055604051601c90600080516020615a2883398151915290600090a250565b606b546001600160a01b0382811691161415611ded5760405162461bcd60e51b815260206004820152600a602482015269086aaa4be9eaaa8849eb60b31b6044820152606401610e70565b606a546040516319dc7ae560e31b81526001600160a01b039091169063cee3d72890611e209084906000906004016153f8565b600060405180830381600087803b158015611e3a57600080fd5b505af1158015611e4e573d6000803e3d6000fd5b505060405160019250600080516020615a288339815191529150600090a250565b6065805467ffffffffffffffff60401b1916600160401b6001600160401b03841602179055604051600a90600080516020615a2883398151915290600090a250565b60006078826001600160401b031681548110611ecf57611ecf61548f565b6000918252602090912001546001600160a01b031692915050565b60335460ff16611f0c5760405162461bcd60e51b8152600401610e7090615315565b60006001611f186121ed565b6001600160401b031615611f685760405162461bcd60e51b81526020600482015260176024820152761393d397d1d1539154d254d7d393d11154d7d1561254d5604a1b6044820152606401610e70565b611f7183613bb4565b611fb05760405162461bcd60e51b815260206004820152601060248201526f4e4f545f454d5054595f4245464f524560801b6044820152606401610e70565b6001611fc260a08501608086016154ca565b6003811115611fd357611fd36154a5565b146120205760405162461bcd60e51b815260206004820152601b60248201527f4245464f52455f4d414348494e455f4e4f545f46494e495348454400000000006044820152606401610e70565b60c083013582146120675760405162461bcd60e51b81526020600482015260116024820152701393d517d6915493d7d4d153911493d3d5607a1b6044820152606401610e70565b6001600160401b038116612082610100850160e08601615083565b6001600160401b0316146120cb5760405162461bcd60e51b815260206004820152601060248201526f494e424f585f4e4f545f41545f4f4e4560801b6044820152606401610e70565b6120dd61012084016101008501615083565b6001600160401b0316156121335760405162461bcd60e51b815260206004820152601c60248201527f504f534954494f4e5f494e5f4d4553534147455f4e4f545f5a45524f000000006044820152606401610e70565b6001612147610140850161012086016154ca565b6003811115612158576121586154a5565b146121a55760405162461bcd60e51b815260206004820152601a60248201527f41465445525f4d414348494e455f4e4f545f46494e49534845440000000000006044820152606401610e70565b60a08301356121c08460006001600160401b038516816135a0565b506121cd600182856132cc565b604051601d90600080516020615a2883398151915290600090a250505050565b607554600160801b90046001600160401b031690565b60335460ff166122255760405162461bcd60e51b8152600401610e7090615315565b806122425760405162461bcd60e51b8152600401610e70906154e5565b60005b818110156123585760006079818585858181106122645761226461548f565b90506020020160208101906122799190614de6565b6001600160a01b03168152602081019190915260400160002060010154600160801b90046001600160401b0316146122e55760405162461bcd60e51b815260206004820152600f60248201526e14d51052d15497d25397d0d2105313608a1b6044820152606401610e70565b6123168383838181106122fa576122fa61548f565b905060200201602081019061230f9190614de6565b6000613c10565b5061234683838381811061232c5761232c61548f565b90506020020160208101906123419190614de6565b613cd5565b8061235081615520565b915050612245565b50604051601690600080516020615a2883398151915290600090a25050565b61237f613d7b565b604051600390600080516020615a2883398151915290600090a2565b604051631b2ce7f360e11b81526001600160a01b03831690633659cfe6906123c7908490600401614dbd565b600060405180830381600087803b1580156123e157600080fd5b505af11580156123f5573d6000803e3d6000fd5b505060405160149250600080516020615a288339815191529150600090a25050565b6068819055604051601a90600080516020615a2883398151915290600090a250565b6000805b607a5481101561249457607a818154811061245a5761245a61548f565b6000918252602090912001546001600160a01b03848116911614156124825750600192915050565b8061248c81615520565b91505061243d565b50600092915050565b6124a5614c98565b6001600160401b03821660009081526076602052604090206040805161018081018252825481526001830154602082015260028301549181019190915260038201546001600160401b038082166060840152600160401b80830482166080850152600160801b808404831660a0860152600160c01b93849004831660c0860152600486015480841660e0870152918204831661010086015281048216610120850152919091041661014082015260059091015461016082015292915050565b6073819055604051600890600080516020615a2883398151915290600090a250565b306001600160a01b037f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a1614156125cf5760405162461bcd60e51b8152600401610e7090615360565b7f0000000000000000000000000ae4dd666748bf0f6db5c149eab1d8ad27820a6a6001600160a01b0316612601612da4565b6001600160a01b0316146126275760405162461bcd60e51b8152600401610e70906153ac565b611c3982826001612dc5565b607e805460ff1916821515179055604051601e90600080516020615a2883398151915290600090a250565b8261267b5760405162461bcd60e51b8152600401610e70906154e5565b82811461269a5760405162461bcd60e51b8152600401610e709061553b565b60005b83811015612731578282828181106126b7576126b761548f565b90506020020160208101906126cc9190615271565b607460008787858181106126e2576126e261548f565b90506020020160208101906126f79190614de6565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558061272981615520565b91505061269d565b50604051600690600080516020615a2883398151915290600090a250505050565b6001600160401b03821660009081526077602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b6000816001600160401b0316116127db5760405162461bcd60e51b81526020600482015260166024820152751253959053125117d0d3d39192549357d411549253d160521b6044820152606401610e70565b6065805467ffffffffffffffff19166001600160401b038316179055604051600990600080516020615a2883398151915290600090a250565b6000607a8281548110611ecf57611ecf61548f565b6001600160a01b038116600090815260796020526040812060010154600160c01b900460ff1680156127835750607554612783906001600160401b031683612752565b6000607a82815481106128815761288161548f565b600091825260209091200154600160a01b90046001600160401b031692915050565b60335460ff166128c55760405162461bcd60e51b8152600401610e7090615315565b826128e25760405162461bcd60e51b8152600401610e70906154e5565b8281146129015760405162461bcd60e51b8152600401610e709061553b565b60005b83811015612a925760006129648686848181106129235761292361548f565b90506020020160208101906129389190614de6565b85858581811061294a5761294a61548f565b905060200201602081019061295f9190614de6565b613df6565b90506001600160401b0381166129ab5760405162461bcd60e51b815260206004820152600c60248201526b1393d517d25397d0d210531360a21b6044820152606401610e70565b612a038686848181106129c0576129c061548f565b90506020020160208101906129d59190614de6565b6001600160a01b03166000908152607960205260409020600101805467ffffffffffffffff60801b19169055565b612a188484848181106129c0576129c061548f565b606e546040516356e9df9760e01b81526001600160401b03831660048201526001600160a01b03909116906356e9df9790602401600060405180830381600087803b158015612a6657600080fd5b505af1158015612a7a573d6000803e3d6000fd5b50505050508080612a8a90615520565b915050612904565b50604051601590600080516020615a2883398151915290600090a250505050565b60007f000000000000000000000000000000000000000000000000000000000000000015612b11576001600160401b0382166000908152607f6020526040902054806127835760405162461bcd60e51b8152600401610e7090615561565b6001600160401b03821660009081526076602052604081206003810154909150600160401b90046001600160401b0316612b5d5760405162461bcd60e51b8152600401610e7090615561565b60040154600160c01b90046001600160401b031692915050565b919050565b612b846132a4565b6001600160a01b0316816001600160a01b03161415612bd65760405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f455343524f5760901b6044820152606401610e70565b607180546001600160a01b0319166001600160a01b038316179055604051601990600080516020615a2883398151915290600090a250565b606b80546001600160a01b0319166001600160a01b0383811691909117909155606a546040516319dc7ae560e31b815291169063cee3d72890612c589084906001906004016153f8565b600060405180830381600087803b158015612c7257600080fd5b505af1158015612c86573d6000803e3d6000fd5b505060405160009250600080516020615a2883398151915291508290a250565b60408051600481526024810182526020810180516001600160e01b03166302881c7960e11b179052905160009182918291606491612ce491906155ae565b600060405180830381855afa9150503d8060008114612d1f576040519150601f19603f3d011682016040523d82523d6000602084013e612d24565b606091505b5091509150818015612d37575080516020145b9250505090565b60335460ff16612d605760405162461bcd60e51b8152600401610e7090615315565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612d9a9190614dbd565b60405180910390a1565b6000600080516020615a088339815191525b546001600160a01b0316919050565b7f49bd798cd84788856140a4cd5030756b4d08a9e4d55db725ec195f232d262a895460ff1615612df85761195883613ec4565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b158015612e3157600080fd5b505afa925050508015612e61575060408051601f3d908101601f19168201909252612e5e918101906155ca565b60015b612ece5760405162461bcd60e51b815260206004820152603860248201527f45524331393637557067726164653a206e6577207365636f6e6461727920696d604482015277706c656d656e746174696f6e206973206e6f74205555505360401b6064820152608401610e70565b7f2b1dbce74324248c222f0ec2d5ed7bd323cfc425b336f0253c5ccfda7265546d8114612f595760405162461bcd60e51b815260206004820152603360248201527f45524331393637557067726164653a20756e737570706f72746564207365636f6044820152721b99185c9e481c1c9bde1a58589b1955555251606a1b6064820152608401610e70565b50611958838383613f7f565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f612f8e6132a4565b604080516001600160a01b03928316815291841660208301520160405180910390a161112381613faa565b612fc1614c98565b612fc9614cfc565b6000612ffb604051806040016040528084815260200160016003811115612ff257612ff26154a5565b90526001614036565b9050612d378160008080438161407b565b6130146140cf565b60008080526076602090815282517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a181958558201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a1819595560408201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195a5560608201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195b8054608085015160a086015160c08701516001600160401b039586166001600160801b031994851617600160401b9387168402176001600160801b03908116600160801b93881684026001600160c01b0390811691909117600160c01b93891684021790965560e08901517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195c80546101008c01516101208d01516101408e0151948c169290991691909117908a169096029590951790911694871690920290941692909217919093169091021790556101608201517fafbc767fed27552cbeceb3d11150dacedabc53b0cc52ac5aa6285a747a18195d556131b89060016155e3565b607560086101000a8154816001600160401b0302191690836001600160401b031602179055507f0000000000000000000000000000000000000000000000000000000000000000156111235760646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561323e57600080fd5b505afa158015613252573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327691906155ca565b60008052607f6020527f18b3a2798575d3a428c1f52e616a74b071539854e037e7d7c535365d474f40335550565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103612db6565b6001600160401b03831660009081526076602052604090206132ee8383614100565b81600201541461332f5760405162461bcd60e51b815260206004820152600c60248201526b434f4e4649524d5f4441544160a01b6044820152606401610e70565b606b54604051630502677360e51b815260048101849052602481018590526001600160a01b039091169063a04cee6090604401600060405180830381600087803b15801561337c57600080fd5b505af1158015613390573d6000803e3d6000fd5b50506075805467ffffffffffffffff19166001600160401b038816179055506133bc90508460016155e3565b6075805467ffffffffffffffff60401b1916600160401b6001600160401b03938416021790556040805185815260208101859052918616917f22ef0479a7ff660660d1c2fe35f1b632cf31675c2d9378db8cec95b00d8ffa3c91015b60405180910390a250505050565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613459576119588361411c565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561349257600080fd5b505afa9250505080156134c2575060408051601f3d908101601f191682019092526134bf918101906155ca565b60015b6135255760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610e70565b600080516020615a0883398151915281146135945760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610e70565b5061195883838361419e565b600060016135b6610140870161012088016154ca565b60038111156135c7576135c76154a5565b14806135f5575060026135e2610140870161012088016154ca565b60038111156135f3576135f36154a5565b145b6136345760405162461bcd60e51b815260206004820152601060248201526f4241445f41465445525f53544154555360801b6044820152606401610e70565b61363c614d21565b6136458561249d565b6060820152606a54604080516221048360e21b815290516001600160a01b03909216916284120c91600480820192602092909190829003018186803b15801561368d57600080fd5b505afa1580156136a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c591906155ca565b81526060810151516136d787866141a7565b146137165760405162461bcd60e51b815260206004820152600f60248201526e0a0a48aacbea6a882a88abe9082a69608b1b6044820152606401610e70565b600061373261372d36899003890160a08a016156d0565b6141e3565b9050600061374861372d368a90038a018a6156d0565b9050806001600160401b0316826001600160401b0316101561379e5760405162461bcd60e51b815260206004820152600f60248201526e494e424f585f4241434b574152445360881b6044820152606401610e70565b806001600160401b0316826001600160401b03161415613844576137cf6137ca368a90038a018a6156d0565b6141f8565b6001600160401b03166137ed6137ca368b90038b0160a08c016156d0565b6001600160401b031610156138445760405162461bcd60e51b815260206004820152601a60248201527f494e424f585f504f535f494e5f4d53475f4241434b57415244530000000000006044820152606401610e70565b60026138586101408a016101208b016154ca565b6003811115613869576138696154a5565b1480613892575060006138876137ca368b90038b0160a08c016156d0565b6001600160401b0316115b156138a557816138a1816156ec565b9250505b82516001600160401b03831611156138f05760405162461bcd60e51b815260206004820152600e60248201526d12539093d617d41054d517d1539160921b6044820152606401610e70565b6001600160401b0382161561399857606a546001600160a01b03166316bf557961391b600185615713565b6040516001600160e01b031960e084901b1681526001600160401b03909116600482015260240160206040518083038186803b15801561395a57600080fd5b505afa15801561396e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061399291906155ca565b60e08401525b506139b290506139ad3688900388018861577a565b614207565b60408201526065546139cd906001600160401b0316436155e3565b6001600160401b0390811660c0830152606082015161012001511615801560a0830152613a2357606081015161012001516001600160401b03166000908152607660205260409020600501546080820152613a33565b6060810151610160015160808201525b613a528160a00151826080015183604001518460e001516068546142a6565b915082821480613a60575082155b613aa35760405162461bcd60e51b81526020600482015260146024820152730aa9c8ab0a08a86a88a88be9c9e888abe9082a6960631b6044820152606401610e70565b613aeb613ab78760a00183600001516141a7565b613ac8836040015143606854614313565b613adf613ada368b90038b018b61577a565b614352565b888560c001518761407b565b60208201526000613afa6121ed565b613b059060016155e3565b90506000613b27876001600160401b0316600090815260766020526040902090565b9050613b33818361437c565b613b4083602001516143ed565b50508181606001516101600151613b556121ed565b6001600160401b03167f4f4caa9e67fb994e349dd35d1ad0ce23053d4323f83ce11dc817b5435031d09684604001518a8660e001516068548860000151604051613ba3959493929190615864565b60405180910390a450949350505050565b60008135158015613bc757506020820135155b8015613be95750613bde6060830160408401615083565b6001600160401b0316155b80156127835750613c006080830160608401615083565b6001600160401b03161592915050565b6001600160a01b0382166000908152607960205260408120805480841115613c6d5760405162461bcd60e51b815260206004820152601060248201526f544f4f5f4c4954544c455f5354414b4560801b6044820152606401610e70565b6000613c7985836158c4565b8584559050613c8886826145db565b60408051838152602081018790526001600160a01b038816917febd093d389ab57f3566918d2c379a2b4d9539e8eb95efad9d5e465457833fde6910160405180910390a295945050505050565b6001600160a01b03808216600081815260796020908152604080832081518083019092529381526001808501546001600160401b03600160401b9091048116938301938452607a8054928301815590945290517ff0440771a29e57e18c66727944770b82cc77924aef333c927ce6bdd2cdb3ae0390910180549251909316600160a01b026001600160e01b031990921694169390931792909217909155611c3982614677565b60335460ff1615613dc15760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610e70565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d8d3390565b6001600160a01b03828116600090815260796020526040808220928416825281206001830154919291600160801b90046001600160401b031680613e665760405162461bcd60e51b81526020600482015260076024820152661393d7d0d2105360ca1b6044820152606401610e70565b60018201546001600160401b03828116600160801b9092041614613ebb5760405162461bcd60e51b815260206004820152600c60248201526b1112519197d25397d0d2105360a21b6044820152606401610e70565b95945050505050565b6001600160a01b0381163b613f3b5760405162461bcd60e51b815260206004820152603760248201527f455243313936373a206e6577207365636f6e6461727920696d706c656d656e74604482015276185d1a5bdb881a5cc81b9bdd08184818dbdb9d1c9858dd604a1b6064820152608401610e70565b807f2b1dbce74324248c222f0ec2d5ed7bd323cfc425b336f0253c5ccfda7265546d5b80546001600160a01b0319166001600160a01b039290921691909117905550565b613f888361483a565b600082511180613f955750805b1561195857613fa4838361487a565b50505050565b6001600160a01b03811661400f5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610e70565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103613f5e565b6000614045836000015161489f565b82846020015160405160200161405d939291906158db565b60405160208183030381529060405280519060200120905092915050565b614083614c98565b61408b614c98565b96875250602086019490945260408501929092526001600160401b0390811660608501529081166080840181905260a0840152431661014083015261016082015290565b600054610100900460ff166140f65760405162461bcd60e51b8152600401610e7090615919565b6140fe614913565b565b604080516020810184905290810182905260009060600161405d565b6001600160a01b0381163b6141895760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610e70565b80600080516020615a08833981519152613f5e565b613f8883614946565b60006141c06141bb368590038501856156d0565b61489f565b826141d160a08601608087016154ca565b60405160200161405d939291906158db565b6020810151600090815b602002015192915050565b602081015160009060016141ed565b6000614211614d72565b8251602001518190600381111561422a5761422a6154a5565b9081600381111561423d5761423d6154a5565b90525060208381015181015190820190600381111561425e5761425e6154a5565b90816003811115614271576142716154a5565b90525061427c614d90565b83515181526020808501515190820152604084015161429e9083908390614986565b949350505050565b600080866142b55760006142b8565b60015b6040516001600160f81b031960f883901b1660208201526021810188905260418101879052606181018690526081810185905290915060a1016040516020818303038152906040528051906020012091505095945050505050565b6040805160208101859052908101839052606081018290526000906080015b6040516020818303038152906040528051906020012090505b9392505050565b6000612783614368836020015160000151614a30565b60208401515161437790614a3b565b614100565b6004820154600160401b90046001600160401b03166143bd5760048201805467ffffffffffffffff60401b1916600160401b436001600160401b0316021790555b600490910180546001600160401b03909216600160801b0267ffffffffffffffff60801b19909216919091179055565b60758054600160801b90046001600160401b031690601061440d836156ec565b825461010092830a6001600160401b03818102199092169282160291909117909255607554600160801b908190048316600090815260766020908152604091829020875181559087015160018201559086015160028201556060860151600382018054608089015160a08a015160c08b01519489166001600160801b031993841617600160401b928a168302176001600160801b03908116918a1688026001600160c01b0390811692909217600160c01b968b1687021790945560e08b0151600487018054998d01516101208e01516101408f0151938d169b9096169a909a17998b16909302989098179093169188169095029091161793909416909302919091179055610160830151600590910155507f0000000000000000000000000000000000000000000000000000000000000000156111235760646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561457e57600080fd5b505afa158015614592573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145b691906155ca565b607554600160801b90046001600160401b03166000908152607f602052604090205550565b6001600160a01b0382166000908152607b6020526040812054906145ff8383615964565b6001600160a01b0385166000908152607b60205260408120829055607c80549293508592909190614631908490615964565b909155505060408051838152602081018390526001600160a01b038616917fa740af14c56e4e04a617b1de1eb20de73270decbaaead14f142aabf3038e5ae29101613418565b6001600160a01b03811660009081526079602052604090206001810154600160c01b900460ff166146d75760405162461bcd60e51b815260206004820152600a6024820152691393d517d4d51052d15160b21b6044820152606401610e70565b600180820154607880546001600160401b039092169290916146f991906158c4565b815481106147095761470961548f565b600091825260209091200154607880546001600160a01b03909216916001600160401b03841690811061473e5761473e61548f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555080607960006078846001600160401b03168154811061478d5761478d61548f565b6000918252602080832091909101546001600160a01b031683528201929092526040019020600101805467ffffffffffffffff19166001600160401b039290921691909117905560788054806147e5576147e561597c565b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b03949094168152607990935250506040812090815560010180546001600160c81b0319169055565b61484381613ec4565b6040516001600160a01b038216907ff7eed2a7fabbf1bec8d55ed5e785cc76622376dde5df4ff15470551e030b813490600090a250565b606061434b8383604051806060016040528060278152602001615a4860279139614a47565b8051805160209182015192820151805190830151604080516c23b637b130b61039ba30ba329d60991b81870152602d810194909452604d8401959095526001600160c01b031960c092831b8116606d850152911b1660758201528251808203605d018152607d909101909252815191012090565b600054610100900460ff1661493a5760405162461bcd60e51b8152600401610e7090615919565b6033805460ff19169055565b61494f8161411c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b604080516002808252606082018352600092839291906020830190803683370190505085519091506149c8906149c38660005b602002015161489f565b614b24565b816000815181106149db576149db61548f565b60209081029190910101526149fc85600160200201516149c38660016149b9565b81600181518110614a0f57614a0f61548f565b602002602001018181525050613ebb6000846001600160401b031683614c48565b8051600090816141ed565b805160009060016141ed565b60606001600160a01b0384163b614aaf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610e70565b600080856001600160a01b031685604051614aca91906155ae565b600060405180830381855af49150503d8060008114614b05576040519150601f19603f3d011682016040523d82523d6000602084013e614b0a565b606091505b5091509150614b1a828286614c5f565b9695505050505050565b60006001836003811115614b3a57614b3a6154a5565b1415614b80576040516b213637b1b59039ba30ba329d60a11b6020820152602c8101839052604c015b604051602081830303815290604052805190602001209050612783565b6002836003811115614b9457614b946154a5565b1415614bca5760405174213637b1b59039ba30ba32961032b93937b932b21d60591b602082015260358101839052605501614b63565b6003836003811115614bde57614bde6154a5565b1415614c0d5760405174213637b1b59039ba30ba3296103a37b7903330b91d60591b6020820152603501614b63565b60405162461bcd60e51b815260206004820152601060248201526f4241445f424c4f434b5f53544154555360801b6044820152606401610e70565b600083838360405160200161433293929190615992565b60608315614c6e57508161434b565b825115614c7e5782518084602001fd5b8160405162461bcd60e51b8152600401610e7091906159d4565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b6040518060400160405280614d0f614d72565b8152602001614d1c614d72565b905290565b60405180610100016040528060008152602001614d3c614c98565b815260006020820152604001614d50614c98565b8152600060208201819052604082018190526060820181905260809091015290565b60405180604001604052806002906020820280368337509192915050565b60405180604001604052806002905b614da7614cfc565b815260200190600190039081614d9f5790505090565b6001600160a01b0391909116815260200190565b6001600160a01b038116811461112357600080fd5b600060208284031215614df857600080fd5b813561434b81614dd1565b600060208284031215614e1557600080fd5b5035919050565b600080828403610160811215614e3157600080fd5b83356001600160401b03811115614e4757600080fd5b84016101c08187031215614e5a57600080fd5b9250610140601f1982011215614e6f57600080fd5b506020830190509250929050565b80356001600160401b0381168114612b7757600080fd5b600080600060608486031215614ea957600080fd5b614eb284614e7d565b95602085013595506040909401359392505050565b60006101608284031215614eda57600080fd5b50919050565b6000806000806101c08587031215614ef757600080fd5b614f0085614e7d565b935060208501359250614f168660408701614ec7565b939692955092936101a00135925050565b801515811461112357600080fd5b60008060408385031215614f4857600080fd5b8235614f5381614dd1565b91506020830135614f6381614f27565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715614fa657614fa6614f6e565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614fd457614fd4614f6e565b604052919050565b60008060408385031215614fef57600080fd5b8235614ffa81614dd1565b91506020838101356001600160401b038082111561501757600080fd5b818601915086601f83011261502b57600080fd5b81358181111561503d5761503d614f6e565b61504f601f8201601f19168501614fac565b9150808252878482850101111561506557600080fd5b80848401858401376000848284010152508093505050509250929050565b60006020828403121561509557600080fd5b61434b82614e7d565b600061016082840312156150b157600080fd5b61434b8383614ec7565b60008083601f8401126150cd57600080fd5b5081356001600160401b038111156150e457600080fd5b6020830191508360208260051b85010111156150ff57600080fd5b9250929050565b6000806020838503121561511957600080fd5b82356001600160401b0381111561512f57600080fd5b61513b858286016150bb565b90969095509350505050565b6000806040838503121561515a57600080fd5b823561516581614dd1565b91506020830135614f6381614dd1565b60006101808201905082518252602083015160208301526040830151604083015260608301516151b060608401826001600160401b03169052565b5060808301516151cb60808401826001600160401b03169052565b5060a08301516151e660a08401826001600160401b03169052565b5060c083015161520160c08401826001600160401b03169052565b5060e083015161521c60e08401826001600160401b03169052565b50610100838101516001600160401b038116848301525050610120838101516001600160401b038116848301525050610140838101516001600160401b03811684830152505061016092830151919092015290565b60006020828403121561528357600080fd5b813561434b81614f27565b600080600080604085870312156152a457600080fd5b84356001600160401b03808211156152bb57600080fd5b6152c7888389016150bb565b909650945060208701359150808211156152e057600080fd5b506152ed878288016150bb565b95989497509550505050565b6000806040838503121561530c57600080fd5b61516583614e7d565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60006020828403121561535557600080fd5b815161434b81614f27565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6001600160a01b039290921682521515602082015260400190565b6000808335601e1984360301811261542a57600080fd5b8301803591506001600160401b0382111561544457600080fd5b6020019150368190038213156150ff57600080fd5b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b803560048110612b7757600080fd5b6000602082840312156154dc57600080fd5b61434b826154bb565b6020808252600b908201526a454d5054595f415252415960a81b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006000198214156155345761553461550a565b5060010190565b6020808252600c908201526b0aea49e9c8ebe988a9c8ea8960a31b604082015260600190565b6020808252600790820152664e4f5f4e4f444560c81b604082015260600190565b60005b8381101561559d578181015183820152602001615585565b83811115613fa45750506000910152565b600082516155c0818460208701615582565b9190910192915050565b6000602082840312156155dc57600080fd5b5051919050565b60006001600160401b038083168185168083038211156156055761560561550a565b01949350505050565b60006080828403121561562057600080fd5b615628614f84565b905082601f83011261563957600080fd5b615641614f84565b80604084018581111561565357600080fd5b845b8181101561566d578035845260209384019301615655565b5081845285605f86011261568057600080fd5b615688614f84565b9250829150608085018681111561569e57600080fd5b808210156156c2576156af82614e7d565b845260208401935060208201915061569e565b505060208301525092915050565b6000608082840312156156e257600080fd5b61434b838361560e565b60006001600160401b03808316818114156157095761570961550a565b6001019392505050565b60006001600160401b03838116908316818110156157335761573361550a565b039392505050565b600060a0828403121561574d57600080fd5b615755614f84565b9050615761838361560e565b815261576f608083016154bb565b602082015292915050565b6000610160828403121561578d57600080fd5b604051606081018181106001600160401b03821117156157af576157af614f6e565b6040526157bc848461573b565b81526157cb8460a0850161573b565b60208201526157dd6101408401614e7d565b60408201529392505050565b604081833760006040838101828152908301915b600281101561582c576001600160401b0361581784614e7d565b168252602092830192909101906001016157fd565b50505061583b608082016154bb565b6004811061585957634e487b7160e01b600052602160045260246000fd5b806080840152505050565b8581526101e0810161587960208301876157e9565b61588960c0830160a088016157e9565b6001600160401b0361589e6101408801614e7d565b1661016083015284610180830152836101a0830152826101c08301529695505050505050565b6000828210156158d6576158d661550a565b500390565b83815282602082015260006004831061590457634e487b7160e01b600052602160045260246000fd5b5060f89190911b604082015260410192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082198211156159775761597761550a565b500190565b634e487b7160e01b600052603160045260246000fd5b83815260006020848184015260408301845182860160005b828110156159c6578151845292840192908401906001016159aa565b509198975050505050505050565b60208152600082518060208401526159f3816040850160208701615582565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbcea8787f128d10b2cc0317b0c3960f9ad447f7f6c1ed189db1083ccffd20f456e416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b130a4a88b5d102c2303c4905ebfd7378faeb598be3e7fecc4b23b4614f647a664736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.