diff --git a/CHANGELOG.md b/CHANGELOG.md index 7da2a42f..e9536cc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.8.1] 2022-12-02 +### Added + +- Support of gnosis chiado testnet + ### Changed - Fixed epoch finalization when running rollups in host mode @@ -124,6 +128,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Specific ERC-20 Portal - Deprecated mock contracts +[0.8.1]: https://github.com/cartesi/rollups/releases/tag/v0.8.1 +[0.8.0]: https://github.com/cartesi/rollups/releases/tag/v0.8.0 [0.7.0]: https://github.com/cartesi/rollups/releases/tag/v0.7.0 [0.6.1]: https://github.com/cartesi/rollups/releases/tag/v0.6.1 [0.6.0]: https://github.com/cartesi/rollups/releases/tag/v0.6.0 diff --git a/onchain/rollups-cli/src/connect.ts b/onchain/rollups-cli/src/connect.ts index 506143d6..2ef1d0f5 100644 --- a/onchain/rollups-cli/src/connect.ts +++ b/onchain/rollups-cli/src/connect.ts @@ -26,6 +26,7 @@ import goerli from "@cartesi/rollups/export/abi/goerli.json"; import polygon_mumbai from "@cartesi/rollups/export/abi/polygon_mumbai.json"; import arbitrum_goerli from "@cartesi/rollups/export/abi/arbitrum_goerli.json"; import optimism_goerli from "@cartesi/rollups/export/abi/optimism_goerli.json"; +import gnosis_chiado from "@cartesi/rollups/export/abi/gnosis_chiado.json"; type DeploymentContract = { address: string; @@ -43,6 +44,7 @@ const deployments: Record = { 80001: polygon_mumbai, 421613: arbitrum_goerli, 420: optimism_goerli, + 10200: gnosis_chiado, }; interface RollupsContracts { diff --git a/onchain/rollups/deployments/gnosis_chiado/.chainId b/onchain/rollups/deployments/gnosis_chiado/.chainId new file mode 100644 index 00000000..6cd35a3e --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/.chainId @@ -0,0 +1 @@ +10200 \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/Bank.json b/onchain/rollups/deployments/gnosis_chiado/Bank.json new file mode 100644 index 00000000..c43f597f --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/Bank.json @@ -0,0 +1,239 @@ +{ + "address": "0x6F3582233305B6D30A34f5fE44BDF78681E32cfA", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "depositTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "transferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x89189f9fd3dba9d021c951679afc6d0682cefb20ed7307839cd4da0fdbf4bda1", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "338252", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xd25b36dbba49358458fcd39c7eaa67634ba15bd1c01890560bbe8fd5e5a72b25", + "transactionHash": "0x89189f9fd3dba9d021c951679afc6d0682cefb20ed7307839cd4da0fdbf4bda1", + "logs": [], + "blockNumber": 1143578, + "cumulativeGasUsed": "338252", + "status": 1, + "byzantium": true + }, + "args": [ + "0x4F046BE54AA9f542887d504e8EA8551286B7ba31" + ], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"depositTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"balanceOf(address)\":{\"params\":{\"_owner\":\"account owner\"}},\"depositTokens(address,uint256)\":{\"details\":\"you may need to call `token.approve(bank, _value)`\",\"params\":{\"_to\":\"account that will have their balance increased by `_value`\",\"_value\":\"amount of tokens to be transfered\"}},\"transferTokens(address,uint256)\":{\"params\":{\"_to\":\"account that will receive `_value` tokens\",\"_value\":\"amount of tokens to be transfered\"}}},\"version\":1},\"userdoc\":{\"events\":{\"Deposit(address,address,uint256)\":{\"notice\":\"`value` tokens were transfered from `from` to bankthe balance of `to` was increased by `value`\"},\"Transfer(address,address,uint256)\":{\"notice\":\"`value` tokens were transfered from the bank to `to`the balance of `from` was decreased by `value`\"}},\"kind\":\"user\",\"methods\":{\"balanceOf(address)\":{\"notice\":\"get balance of `_owner`\"},\"depositTokens(address,uint256)\":{\"notice\":\"transfer `_value` tokens from caller to bankincrease the balance of `_to` by `_value`\"},\"getToken()\":{\"notice\":\"returns the token used internally\"},\"transferTokens(address,uint256)\":{\"notice\":\"transfer `_value` tokens from bank to `_to`decrease the balance of caller by `_value`\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/Bank.sol\":\"Bank\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/Bank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank contract\\npragma solidity ^0.8.0;\\n\\nimport {IBank} from \\\"./IBank.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ncontract Bank is IBank {\\n IERC20 private immutable token;\\n\\n // `balances` maps account/contract addresses to balances\\n mapping(address => uint256) private balances;\\n\\n constructor(address _token) {\\n require(_token != address(0), \\\"Bank: invalid token\\\");\\n token = IERC20(_token);\\n }\\n\\n function getToken() public view override returns (IERC20) {\\n return token;\\n }\\n\\n function balanceOf(address _owner) public view override returns (uint256) {\\n return balances[_owner];\\n }\\n\\n function transferTokens(address _to, uint256 _value) public override {\\n // checks\\n uint256 balance = balances[msg.sender];\\n require(_value <= balance, \\\"Bank: not enough balance\\\");\\n\\n // effects\\n // Note: this should not underflow because we checked that\\n // `_value <= balance` in the `require` above\\n unchecked {\\n balances[msg.sender] = balance - _value;\\n }\\n\\n // interactions\\n // Note: a well-implemented ERC-20 contract should already\\n // require the recipient (in this case, `_to`) to be different\\n // than address(0), so we don't need to check it ourselves\\n require(token.transfer(_to, _value), \\\"Bank: transfer failed\\\");\\n emit Transfer(msg.sender, _to, _value);\\n }\\n\\n function depositTokens(address _to, uint256 _value) public override {\\n // checks\\n require(_to != address(0), \\\"Bank: invalid recipient\\\");\\n\\n // effects\\n // Note: this should not overflow because `IERC20.totalSupply`\\n // returns a `uint256` value, so there can't be more than\\n // `uint256.max` tokens in an ERC-20 contract.\\n balances[_to] += _value;\\n\\n // interactions\\n // Note: transfers tokens to bank, but emits `Deposit` event\\n // with recipient being `_to`\\n require(\\n token.transferFrom(msg.sender, address(this), _value),\\n \\\"Bank: transferFrom failed\\\"\\n );\\n emit Deposit(msg.sender, _to, _value);\\n }\\n}\\n\",\"keccak256\":\"0x1a0ebcbd1c823c592b224959a3b9c4603489c4a3d878b2809c6552528fed672b\",\"license\":\"Apache-2.0\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x60a060405234801561001057600080fd5b5060405161060b38038061060b83398101604081905261002f9161009a565b6001600160a01b0381166100895760405162461bcd60e51b815260206004820152601360248201527f42616e6b3a20696e76616c696420746f6b656e00000000000000000000000000604482015260640160405180910390fd5b6001600160a01b03166080526100ca565b6000602082840312156100ac57600080fd5b81516001600160a01b03811681146100c357600080fd5b9392505050565b6080516105196100f260003960008181605e01528181610196015261033901526105196000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806321df0da71461005157806366168bd71461008d57806370a08231146100a2578063bec3fa17146100d9575b600080fd5b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020015b60405180910390f35b6100a061009b36600461044f565b6100ec565b005b6100cb6100b0366004610479565b6001600160a01b031660009081526020819052604090205490565b604051908152602001610084565b6100a06100e736600461044f565b61029f565b6001600160a01b0382166101475760405162461bcd60e51b815260206004820152601760248201527f42616e6b3a20696e76616c696420726563697069656e7400000000000000000060448201526064015b60405180910390fd5b6001600160a01b0382166000908152602081905260408120805483929061016f90849061049b565b90915550506040516323b872dd60e01b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd906064016020604051808303816000875af11580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b91906104c1565b6102575760405162461bcd60e51b815260206004820152601960248201527f42616e6b3a207472616e7366657246726f6d206661696c656400000000000000604482015260640161013e565b60408051338152602081018390526001600160a01b038416917f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62910160405180910390a25050565b33600090815260208190526040902054808211156102ff5760405162461bcd60e51b815260206004820152601860248201527f42616e6b3a206e6f7420656e6f7567682062616c616e63650000000000000000604482015260640161013e565b336000908152602081905260409081902083830390555163a9059cbb60e01b81526001600160a01b038481166004830152602482018490527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015610382573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a691906104c1565b6103ea5760405162461bcd60e51b815260206004820152601560248201527410985b9ace881d1c985b9cd9995c8819985a5b1959605a1b604482015260640161013e565b604080516001600160a01b03851681526020810184905233917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a2505050565b80356001600160a01b038116811461044a57600080fd5b919050565b6000806040838503121561046257600080fd5b61046b83610433565b946020939093013593505050565b60006020828403121561048b57600080fd5b61049482610433565b9392505050565b600082198211156104bc57634e487b7160e01b600052601160045260246000fd5b500190565b6000602082840312156104d357600080fd5b8151801515811461049457600080fdfea26469706673582212202f52a7f24915f76bd55f8533504eca6464ea1199be7010f33418e3e3cb53374564736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806321df0da71461005157806366168bd71461008d57806370a08231146100a2578063bec3fa17146100d9575b600080fd5b6040516001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681526020015b60405180910390f35b6100a061009b36600461044f565b6100ec565b005b6100cb6100b0366004610479565b6001600160a01b031660009081526020819052604090205490565b604051908152602001610084565b6100a06100e736600461044f565b61029f565b6001600160a01b0382166101475760405162461bcd60e51b815260206004820152601760248201527f42616e6b3a20696e76616c696420726563697069656e7400000000000000000060448201526064015b60405180910390fd5b6001600160a01b0382166000908152602081905260408120805483929061016f90849061049b565b90915550506040516323b872dd60e01b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd906064016020604051808303816000875af11580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b91906104c1565b6102575760405162461bcd60e51b815260206004820152601960248201527f42616e6b3a207472616e7366657246726f6d206661696c656400000000000000604482015260640161013e565b60408051338152602081018390526001600160a01b038416917f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62910160405180910390a25050565b33600090815260208190526040902054808211156102ff5760405162461bcd60e51b815260206004820152601860248201527f42616e6b3a206e6f7420656e6f7567682062616c616e63650000000000000000604482015260640161013e565b336000908152602081905260409081902083830390555163a9059cbb60e01b81526001600160a01b038481166004830152602482018490527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015610382573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a691906104c1565b6103ea5760405162461bcd60e51b815260206004820152601560248201527410985b9ace881d1c985b9cd9995c8819985a5b1959605a1b604482015260640161013e565b604080516001600160a01b03851681526020810184905233917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a2505050565b80356001600160a01b038116811461044a57600080fd5b919050565b6000806040838503121561046257600080fd5b61046b83610433565b946020939093013593505050565b60006020828403121561048b57600080fd5b61049482610433565b9392505050565b600082198211156104bc57634e487b7160e01b600052601160045260246000fd5b500190565b6000602082840312156104d357600080fd5b8151801515811461049457600080fdfea26469706673582212202f52a7f24915f76bd55f8533504eca6464ea1199be7010f33418e3e3cb53374564736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "balanceOf(address)": { + "params": { + "_owner": "account owner" + } + }, + "depositTokens(address,uint256)": { + "details": "you may need to call `token.approve(bank, _value)`", + "params": { + "_to": "account that will have their balance increased by `_value`", + "_value": "amount of tokens to be transfered" + } + }, + "transferTokens(address,uint256)": { + "params": { + "_to": "account that will receive `_value` tokens", + "_value": "amount of tokens to be transfered" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "Deposit(address,address,uint256)": { + "notice": "`value` tokens were transfered from `from` to bankthe balance of `to` was increased by `value`" + }, + "Transfer(address,address,uint256)": { + "notice": "`value` tokens were transfered from the bank to `to`the balance of `from` was decreased by `value`" + } + }, + "kind": "user", + "methods": { + "balanceOf(address)": { + "notice": "get balance of `_owner`" + }, + "depositTokens(address,uint256)": { + "notice": "transfer `_value` tokens from caller to bankincrease the balance of `_to` by `_value`" + }, + "getToken()": { + "notice": "returns the token used internally" + }, + "transferTokens(address,uint256)": { + "notice": "transfer `_value` tokens from bank to `_to`decrease the balance of caller by `_value`" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 3458, + "contract": "contracts/Bank.sol:Bank", + "label": "balances", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/CartesiDAppFactory.json b/onchain/rollups/deployments/gnosis_chiado/CartesiDAppFactory.json new file mode 100644 index 00000000..394798c9 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/CartesiDAppFactory.json @@ -0,0 +1,478 @@ +{ + "address": "0x617E418c50Bf5941C9D6eBA3caE5EcD3bC19356A", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IDiamondCut", + "name": "diamondCutFacet", + "type": "address" + }, + { + "internalType": "contract DiamondInit", + "name": "diamondInit", + "type": "address" + }, + { + "internalType": "contract IBank", + "name": "feeManagerBank", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "diamondCut", + "type": "tuple[]" + } + ], + "internalType": "struct CartesiDAppFactory.FactoryConfig", + "name": "_fConfig", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CartesiDApp", + "name": "application", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "diamondOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "indexed": false, + "internalType": "struct ICartesiDAppFactory.AppConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "ApplicationCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "diamondCut", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "diamondCutFacet", + "outputs": [ + { + "internalType": "contract IDiamondCut", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "diamondInit", + "outputs": [ + { + "internalType": "contract DiamondInit", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeManagerBank", + "outputs": [ + { + "internalType": "contract IBank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "diamondOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "internalType": "struct ICartesiDAppFactory.AppConfig", + "name": "_appConfig", + "type": "tuple" + } + ], + "name": "newApplication", + "outputs": [ + { + "internalType": "contract CartesiDApp", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xcdd072a3b0c5dd6a58d6a826f5479c9b01208c3c86a934e27bba3b452de87957", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "3308820", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc4bedd4b0ca34cf8b0496f9ff98e3089189395ba21f292f497942e56c9463981", + "transactionHash": "0xcdd072a3b0c5dd6a58d6a826f5479c9b01208c3c86a934e27bba3b452de87957", + "logs": [], + "blockNumber": 1143581, + "cumulativeGasUsed": "3308820", + "status": 1, + "byzantium": true + }, + "args": [ + { + "diamondCutFacet": "0x10dc33852b996A4C8A391d6Ed224FD89A3aD1ceE", + "diamondInit": "0xCbEDAB3193dc8027cc403a01cE054695a08E2F34", + "feeManagerBank": "0x6F3582233305B6D30A34f5fE44BDF78681E32cfA", + "diamondCut": [ + { + "facetAddress": "0x8339b06c37d488d51aB838f6C758D61ddb1F1C6c", + "functionSelectors": [ + "0xcdffacc6", + "0x52ef6b2c", + "0xadfca15e", + "0x7a0ed627", + "0x01ffc9a7" + ], + "action": 0 + }, + { + "facetAddress": "0x19C65463Eb32Ff190062686b4ce150Ea1BD80988", + "functionSelectors": [ + "0x8da5cb5b", + "0xf2fde38b" + ], + "action": 0 + }, + { + "facetAddress": "0x0328426f3cf581F1Cf5Ba3492a3d1C5AB551de62", + "functionSelectors": [ + "0xcb1061a6" + ], + "action": 0 + }, + { + "facetAddress": "0xCF8E4cb394805b96290FEcE429E98613aB80b1c3", + "functionSelectors": [ + "0x15e55ce5", + "0x150b7a02" + ], + "action": 0 + }, + { + "facetAddress": "0x1ab5f2688Faec8Dd89e0E2BF23506dB4A4EE5eCA", + "functionSelectors": [ + "0x2abfe7b3", + "0x74956b94" + ], + "action": 0 + }, + { + "facetAddress": "0x81823BDB8ae08E546AD1eCcDa910Ab32B7253343", + "functionSelectors": [ + "0x6e964cea", + "0xa859b983", + "0xe8f56171", + "0xde7a8d11", + "0x7a5bf67c" + ], + "action": 0 + }, + { + "facetAddress": "0xeA8538B194742b992B19e694C13D63120908880e", + "functionSelectors": [ + "0xf32078e8", + "0x1ab6dcab", + "0xa459600e", + "0xe7955244" + ], + "action": 0 + }, + { + "facetAddress": "0x3E1944bB826391e0F47EC96147c20B931BDA5372", + "functionSelectors": [ + "0x6190d81e", + "0x3c0d9958", + "0xa2382036", + "0xf3af7efd", + "0x10517cfc", + "0x8021be81", + "0x83552b4d", + "0xa981588a", + "0x3ad58a27", + "0x5e439a0c", + "0x4f8192c9" + ], + "action": 0 + }, + { + "facetAddress": "0x98Bd941FFa18D10328eF1dea76a146AB6FD78Ee4", + "functionSelectors": [ + "0xbd66528a", + "0x82ae9ef7", + "0x7864b77d", + "0xb97dd9e2", + "0xa3a40ea5", + "0xddf7bcf0", + "0xe17ba012", + "0x54ee1da5", + "0x61b12c66" + ], + "action": 0 + }, + { + "facetAddress": "0x2596c9892cD4c997e6cE22745a2eF8256b0B171f", + "functionSelectors": [ + "0x101494ce", + "0xf6023815", + "0x8219fda4", + "0xd2992f54", + "0x55564a70", + "0xcc8a2451", + "0x1fcc449e" + ], + "action": 0 + } + ] + } + ], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"components\":[{\"internalType\":\"contract IDiamondCut\",\"name\":\"diamondCutFacet\",\"type\":\"address\"},{\"internalType\":\"contract DiamondInit\",\"name\":\"diamondInit\",\"type\":\"address\"},{\"internalType\":\"contract IBank\",\"name\":\"feeManagerBank\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamondCut.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamondCut.FacetCut[]\",\"name\":\"diamondCut\",\"type\":\"tuple[]\"}],\"internalType\":\"struct CartesiDAppFactory.FactoryConfig\",\"name\":\"_fConfig\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"contract CartesiDApp\",\"name\":\"application\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"diamondOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"templateHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"inputDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"challengePeriod\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputLog2Size\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePerClaim\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeManagerOwner\",\"type\":\"address\"},{\"internalType\":\"address payable[]\",\"name\":\"validators\",\"type\":\"address[]\"}],\"indexed\":false,\"internalType\":\"struct ICartesiDAppFactory.AppConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"ApplicationCreated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"diamondCut\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamondCut.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"diamondCutFacet\",\"outputs\":[{\"internalType\":\"contract IDiamondCut\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"diamondInit\",\"outputs\":[{\"internalType\":\"contract DiamondInit\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeManagerBank\",\"outputs\":[{\"internalType\":\"contract IBank\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"diamondOwner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"templateHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"inputDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"challengePeriod\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputLog2Size\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePerClaim\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeManagerOwner\",\"type\":\"address\"},{\"internalType\":\"address payable[]\",\"name\":\"validators\",\"type\":\"address[]\"}],\"internalType\":\"struct ICartesiDAppFactory.AppConfig\",\"name\":\"_appConfig\",\"type\":\"tuple\"}],\"name\":\"newApplication\",\"outputs\":[{\"internalType\":\"contract CartesiDApp\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"newApplication((address,bytes32,uint256,uint256,uint256,uint256,address,address[]))\":{\"params\":{\"_appConfig\":\"application configurations\"},\"returns\":{\"_0\":\"application address\"}}},\"version\":1},\"userdoc\":{\"events\":{\"ApplicationCreated(address,(address,bytes32,uint256,uint256,uint256,uint256,address,address[]))\":{\"notice\":\"Event emitted when a new application is deployed\"}},\"kind\":\"user\",\"methods\":{\"newApplication((address,bytes32,uint256,uint256,uint256,uint256,address,address[]))\":{\"notice\":\"Deploy a new application\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CartesiDAppFactory.sol\":\"CartesiDAppFactory\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/CartesiDApp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n*\\n* Implementation of a diamond.\\n/******************************************************************************/\\n\\nimport {LibDiamond} from \\\"./libraries/LibDiamond.sol\\\";\\nimport {IDiamondCut} from \\\"./interfaces/IDiamondCut.sol\\\";\\n\\ncontract CartesiDApp {\\n constructor(address _contractOwner, address _diamondCutFacet) payable {\\n LibDiamond.setContractOwner(_contractOwner);\\n\\n // Add the diamondCut external function from the diamondCutFacet\\n IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1);\\n bytes4[] memory functionSelectors = new bytes4[](1);\\n functionSelectors[0] = IDiamondCut.diamondCut.selector;\\n cut[0] = IDiamondCut.FacetCut({\\n facetAddress: _diamondCutFacet,\\n action: IDiamondCut.FacetCutAction.Add,\\n functionSelectors: functionSelectors\\n });\\n LibDiamond.diamondCut(cut, address(0), \\\"\\\");\\n }\\n\\n // Find facet for function that is called and execute the\\n // function if a facet is found and return any value.\\n fallback() external payable {\\n LibDiamond.DiamondStorage storage ds;\\n bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;\\n // get diamond storage\\n assembly {\\n ds.slot := position\\n }\\n // get facet from function selector\\n address facet = address(bytes20(ds.facets[msg.sig]));\\n require(facet != address(0), \\\"Diamond: Function does not exist\\\");\\n // Execute external function from facet using delegatecall and return any value.\\n assembly {\\n // copy function selector and any arguments\\n calldatacopy(0, 0, calldatasize())\\n // execute function call using the facet\\n let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)\\n // get any return value\\n returndatacopy(0, 0, returndatasize())\\n // return any return value or error back to the caller\\n switch result\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0x5dcf7607e87afc097540bc36b53f4bf6cf5e037027441218ec5d78362fa7f3b7\",\"license\":\"MIT\"},\"contracts/CartesiDAppFactory.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Cartesi DApp Factory\\npragma solidity ^0.8.0;\\n\\nimport {ICartesiDAppFactory} from \\\"./ICartesiDAppFactory.sol\\\";\\nimport {CartesiDApp} from \\\"./CartesiDApp.sol\\\";\\nimport {IDiamondCut} from \\\"./interfaces/IDiamondCut.sol\\\";\\nimport {IERC173} from \\\"./interfaces/IERC173.sol\\\";\\nimport {DiamondInit, DiamondConfig} from \\\"./upgrade_initializers/DiamondInit.sol\\\";\\nimport {IBank} from \\\"./IBank.sol\\\";\\n\\ncontract CartesiDAppFactory is ICartesiDAppFactory {\\n IDiamondCut public immutable diamondCutFacet;\\n DiamondInit public immutable diamondInit;\\n IBank public immutable feeManagerBank;\\n IDiamondCut.FacetCut[] public diamondCut;\\n\\n struct FactoryConfig {\\n IDiamondCut diamondCutFacet;\\n DiamondInit diamondInit;\\n IBank feeManagerBank;\\n IDiamondCut.FacetCut[] diamondCut;\\n }\\n\\n constructor(FactoryConfig memory _fConfig) {\\n diamondCutFacet = _fConfig.diamondCutFacet;\\n diamondInit = _fConfig.diamondInit;\\n feeManagerBank = _fConfig.feeManagerBank;\\n for (uint256 i; i < _fConfig.diamondCut.length; ++i) {\\n diamondCut.push(_fConfig.diamondCut[i]);\\n }\\n }\\n\\n function newApplication(\\n AppConfig calldata _appConfig\\n ) public returns (CartesiDApp) {\\n CartesiDApp application = new CartesiDApp(\\n address(this),\\n address(diamondCutFacet)\\n );\\n DiamondConfig memory dConfig = DiamondConfig({\\n templateHash: _appConfig.templateHash,\\n inputDuration: _appConfig.inputDuration,\\n challengePeriod: _appConfig.challengePeriod,\\n inputLog2Size: _appConfig.inputLog2Size,\\n feePerClaim: _appConfig.feePerClaim,\\n feeManagerBank: address(feeManagerBank),\\n feeManagerOwner: _appConfig.feeManagerOwner,\\n validators: _appConfig.validators\\n });\\n IDiamondCut(address(application)).diamondCut(\\n diamondCut,\\n address(diamondInit),\\n abi.encodeWithSelector(DiamondInit.init.selector, dConfig)\\n );\\n IERC173(address(application)).transferOwnership(\\n _appConfig.diamondOwner\\n );\\n emit ApplicationCreated(application, _appConfig);\\n return application;\\n }\\n}\\n\",\"keccak256\":\"0xd680ad826ce3ad58352d7cc25cff0ea8b77d0ed86cd8cf45bda75ddafdb3fcb0\",\"license\":\"Apache-2.0\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/ICartesiDAppFactory.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Cartesi DApp Factory interface\\npragma solidity ^0.8.0;\\n\\nimport {CartesiDApp} from \\\"./CartesiDApp.sol\\\";\\n\\ninterface ICartesiDAppFactory {\\n /// @notice application configurations\\n /// @param diamondOwner diamond owner\\n /// @param templateHash state hash of the cartesi machine at t0\\n /// @param inputDuration duration of input accumulation phase in seconds\\n /// @param challengePeriod duration of challenge period in seconds\\n /// @param inputLog2Size size of the input memory range in this machine\\n /// @param feePerClaim fee per claim to reward the validators\\n /// @param feeManagerOwner fee manager owner address\\n /// @param validators initial validator set\\n /// @dev validators have to be unique, if the same validator is added twice\\n /// consensus will never be reached\\n struct AppConfig {\\n // DiamondCutFacet\\n address diamondOwner;\\n // RollupsFacet\\n bytes32 templateHash;\\n uint256 inputDuration;\\n uint256 challengePeriod;\\n // InputFacet\\n uint256 inputLog2Size;\\n // FeeManagerFacet\\n uint256 feePerClaim;\\n address feeManagerOwner;\\n // ValidatorManagerFacet\\n address payable[] validators;\\n }\\n\\n /// @notice Deploy a new application\\n /// @param _appConfig application configurations\\n /// @return application address\\n function newApplication(\\n AppConfig calldata _appConfig\\n ) external returns (CartesiDApp);\\n\\n /// @notice Event emitted when a new application is deployed\\n /// @param application application address\\n /// @param config application configurations\\n event ApplicationCreated(CartesiDApp indexed application, AppConfig config);\\n}\\n\",\"keccak256\":\"0x94983667134381b92e74f48bcf7eba2c53f87f4c36e840f9bec7172e64e2720d\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n enum FacetCutAction {\\n Add,\\n Replace,\\n Remove\\n }\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external;\\n\\n event DiamondCut(FacetCut[] diamondCut, address init, bytes callData);\\n}\\n\",\"keccak256\":\"0x6a3129be1f39b6fec871f2c94bf7debf2d6a4e665547a4d83e7f2def38359e44\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(\\n address _facet\\n ) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses()\\n external\\n view\\n returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(\\n bytes4 _functionSelector\\n ) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0xdc5991b0218ab6b2cd78983c19f74a789a79ec9a9ba756ae05c8dcd512c13e38\",\"license\":\"MIT\"},\"contracts/interfaces/IERC173.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/// @title ERC-173 Contract Ownership Standard\\n/// Note: the ERC-165 identifier for this interface is 0x7f5828d0\\n/* is ERC165 */\\ninterface IERC173 {\\n /// @dev This emits when ownership of a contract changes.\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n /// @notice Get the address of the owner\\n /// @return owner_ The address of the owner.\\n function owner() external view returns (address owner_);\\n\\n /// @notice Set the address of the new owner of the contract\\n /// @dev Set _newOwner to address(0) to renounce any ownership.\\n /// @param _newOwner The address of the new owner of the contract\\n function transferOwnership(address _newOwner) external;\\n}\\n\",\"keccak256\":\"0xc47289cda9c9cdb749612eb82ccb9abf9ab08dca74bdca22292ae7f765a15a5f\",\"license\":\"MIT\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // maps function selectors to the facets that execute the functions.\\n // and maps the selectors to their position in the selectorSlots array.\\n // func selector => address facet, selector position\\n mapping(bytes4 => bytes32) facets;\\n // array of slots of function selectors.\\n // each slot holds 8 function selectors.\\n mapping(uint256 => bytes32) selectorSlots;\\n // The number of function selectors in selectorSlots\\n uint16 selectorCount;\\n // Used to query if a contract implements an interface.\\n // Used to implement ERC-165.\\n mapping(bytes4 => bool) supportedInterfaces;\\n // owner of the contract\\n address contractOwner;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n require(\\n msg.sender == diamondStorage().contractOwner,\\n \\\"LibDiamond: Must be contract owner\\\"\\n );\\n }\\n\\n event DiamondCut(\\n IDiamondCut.FacetCut[] diamondCut,\\n address init,\\n bytes callData\\n );\\n\\n bytes32 constant CLEAR_ADDRESS_MASK =\\n bytes32(uint256(0xffffffffffffffffffffffff));\\n bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));\\n\\n // Internal function version of diamondCut\\n // This code is almost the same as the external diamondCut,\\n // except it is using 'Facet[] memory _diamondCut' instead of\\n // 'Facet[] calldata _diamondCut'.\\n // The code is duplicated to prevent copying calldata to memory which\\n // causes an error for a two dimensional array.\\n function diamondCut(\\n IDiamondCut.FacetCut[] memory _diamondCut,\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addReplaceRemoveFacetSelectors(\\n uint256 _selectorCount,\\n bytes32 _selectorSlot,\\n address _newFacetAddress,\\n IDiamondCut.FacetCutAction _action,\\n bytes4[] memory _selectors\\n ) internal returns (uint256, bytes32) {\\n DiamondStorage storage ds = diamondStorage();\\n require(\\n _selectors.length > 0,\\n \\\"LibDiamondCut: No selectors in facet to cut\\\"\\n );\\n if (_action == IDiamondCut.FacetCutAction.Add) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Add facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) == address(0),\\n \\\"LibDiamondCut: Can't add function that already exists\\\"\\n );\\n // add facet for selector\\n ds.facets[selector] =\\n bytes20(_newFacetAddress) |\\n bytes32(_selectorCount);\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;\\n // clear selector position in slot and add selector\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |\\n (bytes32(selector) >> selectorInSlotPosition);\\n // if slot is full then write it to storage\\n if (selectorInSlotPosition == 224) {\\n // \\\"_selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"_selectorSlot / 8\\\"\\n ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;\\n _selectorSlot = 0;\\n }\\n _selectorCount++;\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Replace) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Replace facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n address oldFacetAddress = address(bytes20(oldFacet));\\n // only useful if immutable functions exist\\n require(\\n oldFacetAddress != address(this),\\n \\\"LibDiamondCut: Can't replace immutable function\\\"\\n );\\n require(\\n oldFacetAddress != _newFacetAddress,\\n \\\"LibDiamondCut: Can't replace function with same function\\\"\\n );\\n require(\\n oldFacetAddress != address(0),\\n \\\"LibDiamondCut: Can't replace function that doesn't exist\\\"\\n );\\n // replace old facet address\\n ds.facets[selector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(_newFacetAddress);\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Remove) {\\n require(\\n _newFacetAddress == address(0),\\n \\\"LibDiamondCut: Remove facet address must be address(0)\\\"\\n );\\n // \\\"_selectorCount >> 3\\\" is a gas efficient division by 8 \\\"_selectorCount / 8\\\"\\n uint256 selectorSlotCount = _selectorCount >> 3;\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotIndex = _selectorCount & 7;\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n if (_selectorSlot == 0) {\\n // get last selectorSlot\\n selectorSlotCount--;\\n _selectorSlot = ds.selectorSlots[selectorSlotCount];\\n selectorInSlotIndex = 7;\\n } else {\\n selectorInSlotIndex--;\\n }\\n bytes4 lastSelector;\\n uint256 oldSelectorsSlotCount;\\n uint256 oldSelectorInSlotPosition;\\n // adding a block here prevents stack too deep error\\n {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) != address(0),\\n \\\"LibDiamondCut: Can't remove function that doesn't exist\\\"\\n );\\n // only useful if immutable functions exist\\n require(\\n address(bytes20(oldFacet)) != address(this),\\n \\\"LibDiamondCut: Can't remove immutable function\\\"\\n );\\n // replace selector with last selector in ds.facets\\n // gets the last selector\\n lastSelector = bytes4(\\n _selectorSlot << (selectorInSlotIndex << 5)\\n );\\n if (lastSelector != selector) {\\n // update last selector slot position info\\n ds.facets[lastSelector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(ds.facets[lastSelector]);\\n }\\n delete ds.facets[selector];\\n uint256 oldSelectorCount = uint16(uint256(oldFacet));\\n // \\\"oldSelectorCount >> 3\\\" is a gas efficient division by 8 \\\"oldSelectorCount / 8\\\"\\n oldSelectorsSlotCount = oldSelectorCount >> 3;\\n // \\\"oldSelectorCount & 7\\\" is a gas efficient modulo by eight \\\"oldSelectorCount % 8\\\"\\n oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;\\n }\\n if (oldSelectorsSlotCount != selectorSlotCount) {\\n bytes32 oldSelectorSlot = ds.selectorSlots[\\n oldSelectorsSlotCount\\n ];\\n // clears the selector we are deleting and puts the last selector in its place.\\n oldSelectorSlot =\\n (oldSelectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n // update storage with the modified slot\\n ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;\\n } else {\\n // clears the selector we are deleting and puts the last selector in its place.\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n }\\n if (selectorInSlotIndex == 0) {\\n delete ds.selectorSlots[selectorSlotCount];\\n _selectorSlot = 0;\\n }\\n }\\n _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;\\n } else {\\n revert(\\\"LibDiamondCut: Incorrect FacetCutAction\\\");\\n }\\n return (_selectorCount, _selectorSlot);\\n }\\n\\n function initializeDiamondCut(\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n if (_init == address(0)) {\\n require(\\n _calldata.length == 0,\\n \\\"LibDiamondCut: _init is address(0) but_calldata is not empty\\\"\\n );\\n } else {\\n require(\\n _calldata.length > 0,\\n \\\"LibDiamondCut: _calldata is empty but _init is not address(0)\\\"\\n );\\n if (_init != address(this)) {\\n enforceHasContractCode(\\n _init,\\n \\\"LibDiamondCut: _init address has no code\\\"\\n );\\n }\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up the error\\n revert(string(error));\\n } else {\\n revert(\\\"LibDiamondCut: _init function reverted\\\");\\n }\\n }\\n }\\n }\\n\\n function enforceHasContractCode(\\n address _contract,\\n string memory _errorMessage\\n ) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n require(contractSize > 0, _errorMessage);\\n }\\n}\\n\",\"keccak256\":\"0x581eb846bee3d62731f4fc5bf21aa9cf744f491075941de685797f107e5d06f2\",\"license\":\"MIT\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"},\"contracts/upgrade_initializers/DiamondInit.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Diamond Initialization Contract\\npragma solidity ^0.8.0;\\n\\n// Rollups-related dependencies\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\n// Diamond-related dependencies\\nimport {LibDiamond} from \\\"../libraries/LibDiamond.sol\\\";\\nimport {IDiamondLoupe} from \\\"../interfaces/IDiamondLoupe.sol\\\";\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\nimport {IERC173} from \\\"../interfaces/IERC173.sol\\\"; // not in openzeppelin-contracts yet\\nimport {IERC165} from \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\n/// @notice diamond configurations\\n/// @param templateHash state hash of the cartesi machine at t0\\n/// @param inputDuration duration of input accumulation phase in seconds\\n/// @param challengePeriod duration of challenge period in seconds\\n/// @param inputLog2Size size of the input memory range in this machine\\n/// @param feePerClaim fee per claim to reward the validators\\n/// @param feeManagerBank fee manager bank address\\n/// @param feeManagerOwner fee manager owner address\\n/// @param validators initial validator set\\n/// @dev validators have to be unique, if the same validator is added twice\\n/// consensus will never be reached\\nstruct DiamondConfig {\\n // RollupsFacet\\n bytes32 templateHash;\\n uint256 inputDuration;\\n uint256 challengePeriod;\\n // InputFacet\\n uint256 inputLog2Size;\\n // FeeManagerFacet\\n uint256 feePerClaim;\\n address feeManagerBank;\\n address feeManagerOwner;\\n // ValidatorManagerFacet\\n address payable[] validators;\\n}\\n\\ncontract DiamondInit {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibInput for LibInput.DiamondStorage;\\n\\n /// @notice initialize the diamond\\n /// @param _dConfig diamond configurations\\n function init(DiamondConfig calldata _dConfig) external {\\n initERC165();\\n initValidatorManager(_dConfig.validators);\\n initRollups(\\n _dConfig.templateHash,\\n _dConfig.inputDuration,\\n _dConfig.challengePeriod\\n );\\n initFeeManager(\\n _dConfig.feePerClaim,\\n _dConfig.feeManagerBank,\\n _dConfig.feeManagerOwner\\n );\\n initInput(_dConfig.inputLog2Size);\\n }\\n\\n /// @notice initialize ERC165 data\\n function initERC165() private {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n ds.supportedInterfaces[type(IERC165).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;\\n ds.supportedInterfaces[type(IERC173).interfaceId] = true;\\n }\\n\\n /// @notice initalize the Input facet\\n /// @param _inputLog2Size size of the input memory range in this machine\\n function initInput(uint256 _inputLog2Size) private {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n\\n require(\\n _inputLog2Size >= 3 && _inputLog2Size <= 64,\\n \\\"Log of input size: [3,64]\\\"\\n );\\n\\n inputDS.inputDriveSize = (1 << _inputLog2Size);\\n\\n // input box gets initialized with one empty input\\n // so that the L2 DApp knows it's own address\\n inputDS.addInternalInput(\\\"\\\");\\n }\\n\\n /// @notice initialize the Validator Manager facet\\n /// @param _validators initial validator set\\n function initValidatorManager(\\n address payable[] memory _validators\\n ) private {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n uint256 maxNumValidators = _validators.length;\\n\\n require(maxNumValidators <= 8, \\\"up to 8 validators\\\");\\n\\n validatorManagerDS.validators = _validators;\\n validatorManagerDS.maxNumValidators = maxNumValidators;\\n\\n // create a new ClaimsMask, with only the consensus goal set,\\n // according to the number of validators\\n validatorManagerDS.claimsMask = LibClaimsMask\\n .newClaimsMaskWithConsensusGoalSet(maxNumValidators);\\n }\\n\\n /// @notice rollups contract initialized\\n /// @param inputDuration duration of input accumulation phase in seconds\\n /// @param challengePeriod duration of challenge period in seconds\\n event RollupsInitialized(uint256 inputDuration, uint256 challengePeriod);\\n\\n /// @notice initialize the Rollups facet\\n /// @param _templateHash state hash of the cartesi machine at t0\\n /// @param _inputDuration duration of input accumulation phase in seconds\\n /// @param _challengePeriod duration of challenge period in seconds\\n function initRollups(\\n bytes32 _templateHash,\\n uint256 _inputDuration,\\n uint256 _challengePeriod\\n ) private {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n rollupsDS.templateHash = _templateHash;\\n rollupsDS.inputDuration = uint32(_inputDuration);\\n rollupsDS.challengePeriod = uint32(_challengePeriod);\\n rollupsDS.inputAccumulationStart = uint32(block.timestamp);\\n rollupsDS.currentPhase_int = uint32(Phase.InputAccumulation);\\n\\n emit RollupsInitialized(_inputDuration, _challengePeriod);\\n }\\n\\n /// @notice FeeManagerImpl contract initialized\\n /// @param feePerClaim fee per claim to reward the validators\\n /// @param feeManagerBank fee manager bank address\\n /// @param feeManagerOwner fee manager owner address\\n event FeeManagerInitialized(\\n uint256 feePerClaim,\\n address feeManagerBank,\\n address feeManagerOwner\\n );\\n\\n /// @notice initalize the Fee Manager facet\\n /// @param _feePerClaim fee per claim to reward the validators\\n /// @param _feeManagerBank fee manager bank address\\n /// @param _feeManagerOwner fee manager owner address\\n function initFeeManager(\\n uint256 _feePerClaim,\\n address _feeManagerBank,\\n address _feeManagerOwner\\n ) private {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n\\n feeManagerDS.feePerClaim = _feePerClaim;\\n feeManagerDS.bank = IBank(_feeManagerBank);\\n feeManagerDS.owner = _feeManagerOwner;\\n\\n emit FeeManagerInitialized(\\n _feePerClaim,\\n _feeManagerBank,\\n _feeManagerOwner\\n );\\n }\\n}\\n\",\"keccak256\":\"0xab936fa5e183f87bb4421ea393b10d37eaf0ab648ad6f0d8d6be49d545a0b644\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x60e06040523480156200001157600080fd5b5060405162003159380380620031598339810160408190526200003491620002d9565b80516001600160a01b039081166080526020820151811660a05260408201511660c05260005b8160600151518110156200012f57600082606001518281518110620000835762000083620004e0565b60209081029190910181015182546001810184556000938452928290208151600294850290910180546001600160a01b039092166001600160a01b0319831681178255938301519294909384926001600160a81b0319161790600160a01b908490811115620000f657620000f6620004f6565b0217905550604082015180516200011891600184019160209091019062000137565b5050508062000127906200050c565b90506200005a565b505062000534565b82805482825590600052602060002090600701600890048101928215620001d85791602002820160005b83821115620001a457835183826101000a81548163ffffffff021916908360e01c0217905550926020019260040160208160030104928301926001030262000161565b8015620001d65782816101000a81549063ffffffff0219169055600401602081600301049283019260010302620001a4565b505b50620001e6929150620001ea565b5090565b5b80821115620001e65760008155600101620001eb565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156200023c576200023c62000201565b60405290565b604051606081016001600160401b03811182821017156200023c576200023c62000201565b604051601f8201601f191681016001600160401b038111828210171562000292576200029262000201565b604052919050565b6001600160a01b0381168114620002b057600080fd5b50565b60006001600160401b03821115620002cf57620002cf62000201565b5060051b60200190565b60006020808385031215620002ed57600080fd5b82516001600160401b03808211156200030557600080fd5b90840190608082870312156200031a57600080fd5b6200032462000217565b825162000331816200029a565b81528284015162000342816200029a565b81850152604083015162000356816200029a565b60408201526060830151828111156200036e57600080fd5b80840193505086601f8401126200038457600080fd5b82516200039b6200039582620002b3565b62000267565b81815260059190911b84018501908581019089831115620003bb57600080fd5b8686015b83811015620004cd57805186811115620003d857600080fd5b87016060818d03601f19011215620003ef57600080fd5b620003f962000242565b8982015162000408816200029a565b81526040820151600381106200041d57600080fd5b818b01526060820151888111156200043457600080fd5b8083019250508c603f8301126200044a57600080fd5b898201516200045d6200039582620002b3565b81815260059190911b8301604001908b8101908f8311156200047e57600080fd5b6040850194505b82851015620004b75784516001600160e01b031981168114620004a757600080fd5b8252938c0193908c019062000485565b60408401525050845250918701918701620003bf565b5060608401525090979650505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6000600182016200052d57634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c051612be2620005776000396000818160f1015261022201526000818161011901526102ce01526000818160c9015261017c0152612be26000f3fe60806040523480156200001157600080fd5b50600436106200005e5760003560e01c806304c01cc7146200006357806394a28f321462000093578063a051e9b314620000c3578063aa9a6e9114620000eb578063e6ee1d4f1462000113575b600080fd5b6200007a6200007436600462000456565b6200013b565b6040516200008a92919062000493565b60405180910390f35b620000aa620000a4366004620004b9565b62000176565b6040516001600160a01b0390911681526020016200008a565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b600081815481106200014c57600080fd5b60009182526020909120600290910201546001600160a01b0381169150600160a01b900460ff1682565b600080307f0000000000000000000000000000000000000000000000000000000000000000604051620001a99062000448565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015620001dd573d6000803e3d6000fd5b5090506000604051806101000160405280856020013581526020018560400135815260200185606001358152602001856080013581526020018560a0013581526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018560c001602081019062000264919062000523565b6001600160a01b031681526020016200028160e087018762000543565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509390945250506040519293506001600160a01b03851692631f931c1c92507f00000000000000000000000000000000000000000000000000000000000000009063af52770160e01b9062000307908790602401620005dd565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199485161790525160e086901b909216825262000350939291600401620006b8565b600060405180830381600087803b1580156200036b57600080fd5b505af115801562000380573d6000803e3d6000fd5b5050506001600160a01b038316905063f2fde38b620003a3602087018762000523565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015620003e557600080fd5b505af1158015620003fa573d6000803e3d6000fd5b50505050816001600160a01b03167f43883daeb0f23afe0fbb9658d1d4c08379520e9654a30f7ea3a9fb3a8f5195bb8560405162000439919062000a2b565b60405180910390a25092915050565b6120df8062000ace83390190565b6000602082840312156200046957600080fd5b5035919050565b600381106200048f57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b038316815260408101620004b2602083018462000470565b9392505050565b600060208284031215620004cc57600080fd5b813567ffffffffffffffff811115620004e457600080fd5b82016101008185031215620004b257600080fd5b6001600160a01b03811681146200050e57600080fd5b50565b80356200051e81620004f8565b919050565b6000602082840312156200053657600080fd5b8135620004b281620004f8565b6000808335601e198436030181126200055b57600080fd5b83018035915067ffffffffffffffff8211156200057757600080fd5b6020019150600581901b36038213156200059057600080fd5b9250929050565b600081518084526020808501945080840160005b83811015620005d25781516001600160a01b031687529582019590820190600101620005ab565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a0820152600060a083015160018060a01b0380821660c08501528060c08601511660e0850152505060e08301516101008081850152506200065261012084018262000597565b949350505050565b6001600160e01b0319169052565b6000815180845260005b81811015620006905760208185018101518683018201520162000672565b81811115620006a3576000602083870101525b50601f01601f19169290920160200192915050565b60608152600060608201855480825260808401915060808160051b8501018760005260208060002060005b848110156200096d57878403607f1901865281546001600160a01b038116855260608501906200071d85870160a083901c60ff1662000470565b506060604086015260018381018054808452600091825260208083209401905b80600784011015620008055784546200075a838260e01b6200065a565b6001600160e01b031962000777848b0160c084901b83166200065a565b6200078b60408501828460a01b166200065a565b6200079f60608501828460801b166200065a565b620007b360808501828460601b166200065a565b620007c760a08501828460401b166200065a565b620007da60c0850182848d1b166200065a565b620007eb60e085018284166200065a565b50506101008201915083850194506008830192506200073d565b93549380831015620008295762000820828660e01b6200065a565b91830191908701905b8083101562000855576200084c8260c087901b6001600160e01b0319166200065a565b91830191908701905b808310156200088157620008788260a087901b6001600160e01b0319166200065a565b91830191908701905b80831015620008ad57620008a482608087901b6001600160e01b0319166200065a565b91830191908701905b80831015620008d957620008d082606087901b6001600160e01b0319166200065a565b91830191908701905b808310156200090557620008fc82604087901b6001600160e01b0319166200065a565b91830191908701905b808310156200092f576200092682868a1b6001600160e01b0319166200065a565b91830191908701905b8083101562000953576200094e826001600160e01b031987166200065a565b908701905b5098860198965050506002929092019150600101620006e3565b50506001600160a01b03881690860152848103604086015262000991818762000668565b98975050505050505050565b6000808335601e19843603018112620009b557600080fd5b830160208101925035905067ffffffffffffffff811115620009d657600080fd5b8060051b36038313156200059057600080fd5b8183526000602080850194508260005b85811015620005d257813562000a0f81620004f8565b6001600160a01b031687529582019590820190600101620009f9565b602081526000823562000a3e81620004f8565b60018060a01b038116602084015250602083013560408301526040830135606083015260608301356080830152608083013560a083015260a083013560c083015262000a8d60c0840162000511565b6001600160a01b03811660e08401525062000aac60e08401846200099d565b6101008481015262000ac461012085018284620009e9565b9594505050505056fe6080604052604051620020df380380620020df833981016040819052620000269162000ddc565b6200003c826200015660201b620000b01760201c565b604080516001808252818301909252600091816020015b60408051606080820183526000808352602083015291810191909152815260200190600190039081620000535750506040805160018082528183019092529192506000919060208083019080368337019050509050631f931c1c60e01b81600081518110620000c657620000c662000e14565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038516815290810160008152602001828152508260008151811062000119576200011962000e14565b60200260200101819052506200014c82600060405180602001604052806000815250620001da60201b620001331760201c565b5050505062001067565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b038481169182179093556040516000805160206200204b833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e546000805160206200204b8339815191529061ffff811690819060009060071615620002395750600381901c60009081526001840160205260409020545b60005b8751811015620002d557620002bb83838a848151811062000261576200026162000e14565b6020026020010151600001518b858151811062000282576200028262000e14565b6020026020010151602001518c8681518110620002a357620002a362000e14565b6020026020010151604001516200036760201b60201c565b909350915080620002cc8162000e56565b9150506200023c565b50828214620002f25760028401805461ffff191661ffff84161790555b60078216156200031557600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738787876040516200034a9392919062000ecf565b60405180910390a16200035e868662000b76565b50505050505050565b600080806000805160206200204b83398151915290506000845111620003e85760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084015b60405180910390fd5b6000856002811115620003ff57620003ff62000e2a565b0362000585576200042a866040518060600160405280602481526020016200206b6024913962000d9b565b60005b84518110156200057e5760008582815181106200044e576200044e62000e14565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c15620004f15760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608401620003df565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a819003620005565760038c901c600090815260018601602052604081209b909b555b8b620005628162000e56565b9c50505050508080620005759062000e56565b9150506200042d565b5062000b6a565b60018560028111156200059c576200059c62000e2a565b03620007b557620005c786604051806060016040528060288152602001620020b76028913962000d9b565b60005b84518110156200057e576000858281518110620005eb57620005eb62000e14565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c308103620006825760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b6064820152608401620003df565b896001600160a01b0316816001600160a01b031603620006fa5760405162461bcd60e51b815260206004820152603860248201526000805160206200202b83398151915260448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608401620003df565b6001600160a01b038116620007675760405162461bcd60e51b815260206004820152603860248201526000805160206200202b83398151915260448201527f6374696f6e207468617420646f65736e277420657869737400000000000000006064820152608401620003df565b506001600160e01b031990911660009081526020849052604090206001600160601b03919091166001600160601b031960608a901b1617905580620007ac8162000e56565b915050620005ca565b6002856002811115620007cc57620007cc62000e2a565b0362000b11576001600160a01b03861615620008515760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608401620003df565b600388901c6007891660005b865181101562000aec5760008a90036200089e57826200087d8162000fd6565b60008181526001870160205260409020549b50935060079250620008ae9050565b81620008aa8162000fd6565b9250505b6000806000808a8581518110620008c957620008c962000e14565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6200096b5760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608401620003df565b30606082901c03620009d75760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608401620003df565b600587901b8f901b94506001600160e01b03198086169083161462000a29576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166001600160601b0383161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e016905085821462000a90576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c17905562000ab4565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b8460000362000ad357600086815260018801602052604081208190559c505b505050808062000ae39062000e56565b9150506200085d565b508062000afb83600862000ff0565b62000b07919062001012565b9950505062000b6a565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608401620003df565b50959694955050505050565b6001600160a01b03821662000c005780511562000bfc5760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d707479000000006064820152608401620003df565b5050565b600081511162000c795760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f7420616464726573732830290000006064820152608401620003df565b6001600160a01b038216301462000caf5762000caf826040518060600160405280602881526020016200208f6028913962000d9b565b600080836001600160a01b03168360405162000ccc91906200102d565b600060405180830381855af49150503d806000811462000d09576040519150601f19603f3d011682016040523d82523d6000602084013e62000d0e565b606091505b50915091508162000d955780511562000d3d578060405162461bcd60e51b8152600401620003df91906200104b565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b6064820152608401620003df565b50505050565b813b818162000d955760405162461bcd60e51b8152600401620003df91906200104b565b80516001600160a01b038116811462000dd757600080fd5b919050565b6000806040838503121562000df057600080fd5b62000dfb8362000dbf565b915062000e0b6020840162000dbf565b90509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000e6b5762000e6b62000e40565b5060010190565b60005b8381101562000e8f57818101518382015260200162000e75565b8381111562000d955750506000910152565b6000815180845262000ebb81602086016020860162000e72565b601f01601f19169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562000fa457898403607f19018652815180516001600160a01b0316855283810151898601906003811062000f4057634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b8083101562000f8e5783516001600160e01b031916825292860192600192909201919086019062000f62565b5097850197955050509082019060010162000ef8565b50506001600160a01b038a1690880152868103604088015262000fc8818962000ea1565b9a9950505050505050505050565b60008162000fe85762000fe862000e40565b506000190190565b60008160001904831182151516156200100d576200100d62000e40565b500290565b6000821982111562001028576200102862000e40565b500190565b600082516200104181846020870162000e72565b9190910192915050565b60208152600062001060602083018462000ea1565b9392505050565b610fb480620010776000396000f3fe60806040523661000b57005b600080356001600160e01b0319168152600080516020610eeb8339815191526020819052604090912054819060601c8061008c5760405162461bcd60e51b815260206004820181905260248201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460448201526064015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156100ab573d6000f35b3d6000fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b03848116918217909355604051600080516020610eeb833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54600080516020610eeb8339815191529061ffff8116908190600090600716156101905750600381901c60009081526001840160205260409020545b60005b87518110156102175761020083838a84815181106101b3576101b3610cb3565b6020026020010151600001518b85815181106101d1576101d1610cb3565b6020026020010151602001518c86815181106101ef576101ef610cb3565b6020026020010151604001516102a3565b90935091508061020f81610cdf565b915050610193565b508282146102335760028401805461ffff191661ffff84161790555b600782161561025557600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67387878760405161028893929190610d66565b60405180910390a161029a8686610a7f565b50505050505050565b60008080600080516020610eeb8339815191529050600084511161031d5760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608401610083565b600085600281111561033157610331610cf8565b0361049e5761035886604051806060016040528060248152602001610f0b60249139610c92565b60005b845181101561049857600085828151811061037857610378610cb3565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c156104115760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b6064820152608401610083565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036104755760038c901c600090815260018601602052604081209b909b555b8b61047f81610cdf565b9c5050505050808061049090610cdf565b91505061035b565b50610a73565b60018560028111156104b2576104b2610cf8565b036106e1576104d986604051806060016040528060288152602001610f5760289139610c92565b60005b84518110156104985760008582815181106104f9576104f9610cb3565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c30810361058e5760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b6064820152608401610083565b896001600160a01b0316816001600160a01b0316036106155760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608401610083565b6001600160a01b0381166106915760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e277420657869737400000000000000006064820152608401610083565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b16179055806106d981610cdf565b9150506104dc565b60028560028111156106f5576106f5610cf8565b03610a1b576001600160a01b038616156107705760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b6064820152608401610083565b600388901c6007891660005b86518110156109fb5760008a90036107b8578261079881610e66565b60008181526001870160205260409020549b509350600792506107c69050565b816107c281610e66565b9250505b6000806000808a85815181106107de576107de610cb3565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c61087e5760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608401610083565b30606082901c036108e85760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608401610083565b600587901b8f901b94506001600160e01b03198086169083161461093e576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e01690508582146109a3576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c1790556109c7565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b846000036109e557600086815260018801602052604081208190559c505b50505080806109f390610cdf565b91505061077c565b5080610a08836008610e7d565b610a129190610e9c565b99505050610a73565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608401610083565b50959694955050505050565b6001600160a01b038216610b0657805115610b025760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d707479000000006064820152608401610083565b5050565b6000815111610b7d5760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f7420616464726573732830290000006064820152608401610083565b6001600160a01b0382163014610baf57610baf82604051806060016040528060288152602001610f2f60289139610c92565b600080836001600160a01b031683604051610bca9190610eb4565b600060405180830381855af49150503d8060008114610c05576040519150601f19603f3d011682016040523d82523d6000602084013e610c0a565b606091505b509150915081610c8c57805115610c35578060405162461bcd60e51b81526004016100839190610ed0565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b6064820152608401610083565b50505050565b813b8181610c8c5760405162461bcd60e51b81526004016100839190610ed0565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610cf157610cf1610cc9565b5060010190565b634e487b7160e01b600052602160045260246000fd5b60005b83811015610d29578181015183820152602001610d11565b83811115610c8c5750506000910152565b60008151808452610d52816020860160208601610d0e565b601f01601f19169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b84811015610e3657898403607f19018652815180516001600160a01b03168552838101518986019060038110610dd557634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b80831015610e215783516001600160e01b0319168252928601926001929092019190860190610df7565b50978501979550505090820190600101610d8f565b50506001600160a01b038a16908801528681036040880152610e588189610d3a565b9a9950505050505050505050565b600081610e7557610e75610cc9565b506000190190565b6000816000190483118215151615610e9757610e97610cc9565b500290565b60008219821115610eaf57610eaf610cc9565b500190565b60008251610ec6818460208701610d0e565b9190910192915050565b602081526000610ee36020830184610d3a565b939250505056fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a2646970667358221220b69d20db35c4d09a73e0fae3e21d3418a25fad2ce81b24fb3dc4d5be9801ee0264736f6c634300080d00334c69624469616d6f6e644375743a2043616e2774207265706c6163652066756ec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a26469706673582212208c9f838fc49aa6679eca5cd55b9149c489d8b7be3f357fb87d75c3dff286a30c64736f6c634300080d0033", + "deployedBytecode": "0x60806040523480156200001157600080fd5b50600436106200005e5760003560e01c806304c01cc7146200006357806394a28f321462000093578063a051e9b314620000c3578063aa9a6e9114620000eb578063e6ee1d4f1462000113575b600080fd5b6200007a6200007436600462000456565b6200013b565b6040516200008a92919062000493565b60405180910390f35b620000aa620000a4366004620004b9565b62000176565b6040516001600160a01b0390911681526020016200008a565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b620000aa7f000000000000000000000000000000000000000000000000000000000000000081565b600081815481106200014c57600080fd5b60009182526020909120600290910201546001600160a01b0381169150600160a01b900460ff1682565b600080307f0000000000000000000000000000000000000000000000000000000000000000604051620001a99062000448565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015620001dd573d6000803e3d6000fd5b5090506000604051806101000160405280856020013581526020018560400135815260200185606001358152602001856080013581526020018560a0013581526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020018560c001602081019062000264919062000523565b6001600160a01b031681526020016200028160e087018762000543565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052509390945250506040519293506001600160a01b03851692631f931c1c92507f00000000000000000000000000000000000000000000000000000000000000009063af52770160e01b9062000307908790602401620005dd565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199485161790525160e086901b909216825262000350939291600401620006b8565b600060405180830381600087803b1580156200036b57600080fd5b505af115801562000380573d6000803e3d6000fd5b5050506001600160a01b038316905063f2fde38b620003a3602087018762000523565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015620003e557600080fd5b505af1158015620003fa573d6000803e3d6000fd5b50505050816001600160a01b03167f43883daeb0f23afe0fbb9658d1d4c08379520e9654a30f7ea3a9fb3a8f5195bb8560405162000439919062000a2b565b60405180910390a25092915050565b6120df8062000ace83390190565b6000602082840312156200046957600080fd5b5035919050565b600381106200048f57634e487b7160e01b600052602160045260246000fd5b9052565b6001600160a01b038316815260408101620004b2602083018462000470565b9392505050565b600060208284031215620004cc57600080fd5b813567ffffffffffffffff811115620004e457600080fd5b82016101008185031215620004b257600080fd5b6001600160a01b03811681146200050e57600080fd5b50565b80356200051e81620004f8565b919050565b6000602082840312156200053657600080fd5b8135620004b281620004f8565b6000808335601e198436030181126200055b57600080fd5b83018035915067ffffffffffffffff8211156200057757600080fd5b6020019150600581901b36038213156200059057600080fd5b9250929050565b600081518084526020808501945080840160005b83811015620005d25781516001600160a01b031687529582019590820190600101620005ab565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a0820152600060a083015160018060a01b0380821660c08501528060c08601511660e0850152505060e08301516101008081850152506200065261012084018262000597565b949350505050565b6001600160e01b0319169052565b6000815180845260005b81811015620006905760208185018101518683018201520162000672565b81811115620006a3576000602083870101525b50601f01601f19169290920160200192915050565b60608152600060608201855480825260808401915060808160051b8501018760005260208060002060005b848110156200096d57878403607f1901865281546001600160a01b038116855260608501906200071d85870160a083901c60ff1662000470565b506060604086015260018381018054808452600091825260208083209401905b80600784011015620008055784546200075a838260e01b6200065a565b6001600160e01b031962000777848b0160c084901b83166200065a565b6200078b60408501828460a01b166200065a565b6200079f60608501828460801b166200065a565b620007b360808501828460601b166200065a565b620007c760a08501828460401b166200065a565b620007da60c0850182848d1b166200065a565b620007eb60e085018284166200065a565b50506101008201915083850194506008830192506200073d565b93549380831015620008295762000820828660e01b6200065a565b91830191908701905b8083101562000855576200084c8260c087901b6001600160e01b0319166200065a565b91830191908701905b808310156200088157620008788260a087901b6001600160e01b0319166200065a565b91830191908701905b80831015620008ad57620008a482608087901b6001600160e01b0319166200065a565b91830191908701905b80831015620008d957620008d082606087901b6001600160e01b0319166200065a565b91830191908701905b808310156200090557620008fc82604087901b6001600160e01b0319166200065a565b91830191908701905b808310156200092f576200092682868a1b6001600160e01b0319166200065a565b91830191908701905b8083101562000953576200094e826001600160e01b031987166200065a565b908701905b5098860198965050506002929092019150600101620006e3565b50506001600160a01b03881690860152848103604086015262000991818762000668565b98975050505050505050565b6000808335601e19843603018112620009b557600080fd5b830160208101925035905067ffffffffffffffff811115620009d657600080fd5b8060051b36038313156200059057600080fd5b8183526000602080850194508260005b85811015620005d257813562000a0f81620004f8565b6001600160a01b031687529582019590820190600101620009f9565b602081526000823562000a3e81620004f8565b60018060a01b038116602084015250602083013560408301526040830135606083015260608301356080830152608083013560a083015260a083013560c083015262000a8d60c0840162000511565b6001600160a01b03811660e08401525062000aac60e08401846200099d565b6101008481015262000ac461012085018284620009e9565b9594505050505056fe6080604052604051620020df380380620020df833981016040819052620000269162000ddc565b6200003c826200015660201b620000b01760201c565b604080516001808252818301909252600091816020015b60408051606080820183526000808352602083015291810191909152815260200190600190039081620000535750506040805160018082528183019092529192506000919060208083019080368337019050509050631f931c1c60e01b81600081518110620000c657620000c662000e14565b6001600160e01b031990921660209283029190910182015260408051606081019091526001600160a01b038516815290810160008152602001828152508260008151811062000119576200011962000e14565b60200260200101819052506200014c82600060405180602001604052806000815250620001da60201b620001331760201c565b5050505062001067565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b038481169182179093556040516000805160206200204b833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e546000805160206200204b8339815191529061ffff811690819060009060071615620002395750600381901c60009081526001840160205260409020545b60005b8751811015620002d557620002bb83838a848151811062000261576200026162000e14565b6020026020010151600001518b858151811062000282576200028262000e14565b6020026020010151602001518c8681518110620002a357620002a362000e14565b6020026020010151604001516200036760201b60201c565b909350915080620002cc8162000e56565b9150506200023c565b50828214620002f25760028401805461ffff191661ffff84161790555b60078216156200031557600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738787876040516200034a9392919062000ecf565b60405180910390a16200035e868662000b76565b50505050505050565b600080806000805160206200204b83398151915290506000845111620003e85760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084015b60405180910390fd5b6000856002811115620003ff57620003ff62000e2a565b0362000585576200042a866040518060600160405280602481526020016200206b6024913962000d9b565b60005b84518110156200057e5760008582815181106200044e576200044e62000e14565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c15620004f15760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152608401620003df565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a819003620005565760038c901c600090815260018601602052604081209b909b555b8b620005628162000e56565b9c50505050508080620005759062000e56565b9150506200042d565b5062000b6a565b60018560028111156200059c576200059c62000e2a565b03620007b557620005c786604051806060016040528060288152602001620020b76028913962000d9b565b60005b84518110156200057e576000858281518110620005eb57620005eb62000e14565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c308103620006825760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b6064820152608401620003df565b896001600160a01b0316816001600160a01b031603620006fa5760405162461bcd60e51b815260206004820152603860248201526000805160206200202b83398151915260448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608401620003df565b6001600160a01b038116620007675760405162461bcd60e51b815260206004820152603860248201526000805160206200202b83398151915260448201527f6374696f6e207468617420646f65736e277420657869737400000000000000006064820152608401620003df565b506001600160e01b031990911660009081526020849052604090206001600160601b03919091166001600160601b031960608a901b1617905580620007ac8162000e56565b915050620005ca565b6002856002811115620007cc57620007cc62000e2a565b0362000b11576001600160a01b03861615620008515760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152608401620003df565b600388901c6007891660005b865181101562000aec5760008a90036200089e57826200087d8162000fd6565b60008181526001870160205260409020549b50935060079250620008ae9050565b81620008aa8162000fd6565b9250505b6000806000808a8581518110620008c957620008c962000e14565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6200096b5760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608401620003df565b30606082901c03620009d75760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608401620003df565b600587901b8f901b94506001600160e01b03198086169083161462000a29576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166001600160601b0383161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e016905085821462000a90576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c17905562000ab4565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b8460000362000ad357600086815260018801602052604081208190559c505b505050808062000ae39062000e56565b9150506200085d565b508062000afb83600862000ff0565b62000b07919062001012565b9950505062000b6a565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608401620003df565b50959694955050505050565b6001600160a01b03821662000c005780511562000bfc5760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d707479000000006064820152608401620003df565b5050565b600081511162000c795760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f7420616464726573732830290000006064820152608401620003df565b6001600160a01b038216301462000caf5762000caf826040518060600160405280602881526020016200208f6028913962000d9b565b600080836001600160a01b03168360405162000ccc91906200102d565b600060405180830381855af49150503d806000811462000d09576040519150601f19603f3d011682016040523d82523d6000602084013e62000d0e565b606091505b50915091508162000d955780511562000d3d578060405162461bcd60e51b8152600401620003df91906200104b565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b6064820152608401620003df565b50505050565b813b818162000d955760405162461bcd60e51b8152600401620003df91906200104b565b80516001600160a01b038116811462000dd757600080fd5b919050565b6000806040838503121562000df057600080fd5b62000dfb8362000dbf565b915062000e0b6020840162000dbf565b90509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000e6b5762000e6b62000e40565b5060010190565b60005b8381101562000e8f57818101518382015260200162000e75565b8381111562000d955750506000910152565b6000815180845262000ebb81602086016020860162000e72565b601f01601f19169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101562000fa457898403607f19018652815180516001600160a01b0316855283810151898601906003811062000f4057634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b8083101562000f8e5783516001600160e01b031916825292860192600192909201919086019062000f62565b5097850197955050509082019060010162000ef8565b50506001600160a01b038a1690880152868103604088015262000fc8818962000ea1565b9a9950505050505050505050565b60008162000fe85762000fe862000e40565b506000190190565b60008160001904831182151516156200100d576200100d62000e40565b500290565b6000821982111562001028576200102862000e40565b500190565b600082516200104181846020870162000e72565b9190910192915050565b60208152600062001060602083018462000ea1565b9392505050565b610fb480620010776000396000f3fe60806040523661000b57005b600080356001600160e01b0319168152600080516020610eeb8339815191526020819052604090912054819060601c8061008c5760405162461bcd60e51b815260206004820181905260248201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f7420657869737460448201526064015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156100ab573d6000f35b3d6000fd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b03848116918217909355604051600080516020610eeb833981519152939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54600080516020610eeb8339815191529061ffff8116908190600090600716156101905750600381901c60009081526001840160205260409020545b60005b87518110156102175761020083838a84815181106101b3576101b3610cb3565b6020026020010151600001518b85815181106101d1576101d1610cb3565b6020026020010151602001518c86815181106101ef576101ef610cb3565b6020026020010151604001516102a3565b90935091508061020f81610cdf565b915050610193565b508282146102335760028401805461ffff191661ffff84161790555b600782161561025557600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb67387878760405161028893929190610d66565b60405180910390a161029a8686610a7f565b50505050505050565b60008080600080516020610eeb8339815191529050600084511161031d5760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b6064820152608401610083565b600085600281111561033157610331610cf8565b0361049e5761035886604051806060016040528060248152602001610f0b60249139610c92565b60005b845181101561049857600085828151811061037857610378610cb3565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c156104115760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b6064820152608401610083565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036104755760038c901c600090815260018601602052604081209b909b555b8b61047f81610cdf565b9c5050505050808061049090610cdf565b91505061035b565b50610a73565b60018560028111156104b2576104b2610cf8565b036106e1576104d986604051806060016040528060288152602001610f5760289139610c92565b60005b84518110156104985760008582815181106104f9576104f9610cb3565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c30810361058e5760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b6064820152608401610083565b896001600160a01b0316816001600160a01b0316036106155760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152608401610083565b6001600160a01b0381166106915760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e277420657869737400000000000000006064820152608401610083565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b16179055806106d981610cdf565b9150506104dc565b60028560028111156106f5576106f5610cf8565b03610a1b576001600160a01b038616156107705760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b6064820152608401610083565b600388901c6007891660005b86518110156109fb5760008a90036107b8578261079881610e66565b60008181526001870160205260409020549b509350600792506107c69050565b816107c281610e66565b9250505b6000806000808a85815181106107de576107de610cb3565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c61087e5760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152608401610083565b30606082901c036108e85760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b6064820152608401610083565b600587901b8f901b94506001600160e01b03198086169083161461093e576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e01690508582146109a3576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c1790556109c7565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b846000036109e557600086815260018801602052604081208190559c505b50505080806109f390610cdf565b91505061077c565b5080610a08836008610e7d565b610a129190610e9c565b99505050610a73565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b6064820152608401610083565b50959694955050505050565b6001600160a01b038216610b0657805115610b025760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d707479000000006064820152608401610083565b5050565b6000815111610b7d5760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f7420616464726573732830290000006064820152608401610083565b6001600160a01b0382163014610baf57610baf82604051806060016040528060288152602001610f2f60289139610c92565b600080836001600160a01b031683604051610bca9190610eb4565b600060405180830381855af49150503d8060008114610c05576040519150601f19603f3d011682016040523d82523d6000602084013e610c0a565b606091505b509150915081610c8c57805115610c35578060405162461bcd60e51b81526004016100839190610ed0565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b6064820152608401610083565b50505050565b813b8181610c8c5760405162461bcd60e51b81526004016100839190610ed0565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610cf157610cf1610cc9565b5060010190565b634e487b7160e01b600052602160045260246000fd5b60005b83811015610d29578181015183820152602001610d11565b83811115610c8c5750506000910152565b60008151808452610d52816020860160208601610d0e565b601f01601f19169290920160200192915050565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b84811015610e3657898403607f19018652815180516001600160a01b03168552838101518986019060038110610dd557634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b80831015610e215783516001600160e01b0319168252928601926001929092019190860190610df7565b50978501979550505090820190600101610d8f565b50506001600160a01b038a16908801528681036040880152610e588189610d3a565b9a9950505050505050505050565b600081610e7557610e75610cc9565b506000190190565b6000816000190483118215151615610e9757610e97610cc9565b500290565b60008219821115610eaf57610eaf610cc9565b500190565b60008251610ec6818460208701610d0e565b9190910192915050565b602081526000610ee36020830184610d3a565b939250505056fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a2646970667358221220b69d20db35c4d09a73e0fae3e21d3418a25fad2ce81b24fb3dc4d5be9801ee0264736f6c634300080d00334c69624469616d6f6e644375743a2043616e2774207265706c6163652066756ec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a26469706673582212208c9f838fc49aa6679eca5cd55b9149c489d8b7be3f357fb87d75c3dff286a30c64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "newApplication((address,bytes32,uint256,uint256,uint256,uint256,address,address[]))": { + "params": { + "_appConfig": "application configurations" + }, + "returns": { + "_0": "application address" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "ApplicationCreated(address,(address,bytes32,uint256,uint256,uint256,uint256,address,address[]))": { + "notice": "Event emitted when a new application is deployed" + } + }, + "kind": "user", + "methods": { + "newApplication((address,bytes32,uint256,uint256,uint256,uint256,address,address[]))": { + "notice": "Deploy a new application" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 3751, + "contract": "contracts/CartesiDAppFactory.sol:CartesiDAppFactory", + "label": "diamondCut", + "offset": 0, + "slot": "0", + "type": "t_array(t_struct(FacetCut)6868_storage)dyn_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_bytes4)dyn_storage": { + "base": "t_bytes4", + "encoding": "dynamic_array", + "label": "bytes4[]", + "numberOfBytes": "32" + }, + "t_array(t_struct(FacetCut)6868_storage)dyn_storage": { + "base": "t_struct(FacetCut)6868_storage", + "encoding": "dynamic_array", + "label": "struct IDiamondCut.FacetCut[]", + "numberOfBytes": "32" + }, + "t_bytes4": { + "encoding": "inplace", + "label": "bytes4", + "numberOfBytes": "4" + }, + "t_enum(FacetCutAction)6859": { + "encoding": "inplace", + "label": "enum IDiamondCut.FacetCutAction", + "numberOfBytes": "1" + }, + "t_struct(FacetCut)6868_storage": { + "encoding": "inplace", + "label": "struct IDiamondCut.FacetCut", + "members": [ + { + "astId": 6861, + "contract": "contracts/CartesiDAppFactory.sol:CartesiDAppFactory", + "label": "facetAddress", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 6864, + "contract": "contracts/CartesiDAppFactory.sol:CartesiDAppFactory", + "label": "action", + "offset": 20, + "slot": "0", + "type": "t_enum(FacetCutAction)6859" + }, + { + "astId": 6867, + "contract": "contracts/CartesiDAppFactory.sol:CartesiDAppFactory", + "label": "functionSelectors", + "offset": 0, + "slot": "1", + "type": "t_array(t_bytes4)dyn_storage" + } + ], + "numberOfBytes": "64" + } + } + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/DiamondCutFacet.json b/onchain/rollups/deployments/gnosis_chiado/DiamondCutFacet.json new file mode 100644 index 00000000..7e9c7092 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/DiamondCutFacet.json @@ -0,0 +1,135 @@ +{ + "address": "0x10dc33852b996A4C8A391d6Ed224FD89A3aD1ceE", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x3ef7bb7fa53cb781bb1680345346947c97d5c129813de8f01df938327664eec9", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "1070442", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3ad02d6a64a5aa50f28d579b5ae9678c585881076c10e026e461f87229675296", + "transactionHash": "0x3ef7bb7fa53cb781bb1680345346947c97d5c129813de8f01df938327664eec9", + "logs": [], + "blockNumber": 1143552, + "cumulativeGasUsed": "1070442", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamondCut.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"indexed\":false,\"internalType\":\"struct IDiamondCut.FacetCut[]\",\"name\":\"diamondCut\",\"type\":\"tuple[]\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"init\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"}],\"name\":\"DiamondCut\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"enum IDiamondCut.FacetCutAction\",\"name\":\"action\",\"type\":\"uint8\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamondCut.FacetCut[]\",\"name\":\"_diamondCut\",\"type\":\"tuple[]\"},{\"internalType\":\"address\",\"name\":\"_init\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_calldata\",\"type\":\"bytes\"}],\"name\":\"diamondCut\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"diamondCut((address,uint8,bytes4[])[],address,bytes)\":{\"params\":{\"_calldata\":\"A function call, including function selector and arguments _calldata is executed with delegatecall on _init\",\"_diamondCut\":\"Contains the facet addresses and function selectors\",\"_init\":\"The address of the contract or facet to execute _calldata\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"diamondCut((address,uint8,bytes4[])[],address,bytes)\":{\"notice\":\"Add/replace/remove any number of functions and optionally execute a function with delegatecall\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/DiamondCutFacet.sol\":\"DiamondCutFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/facets/DiamondCutFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\nimport {LibDiamond} from \\\"../libraries/LibDiamond.sol\\\";\\n\\ncontract DiamondCutFacet is IDiamondCut {\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external override {\\n LibDiamond.enforceIsContractOwner();\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorCount >> 3\\\" is a gas efficient division by 8 \\\"selectorCount / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = LibDiamond\\n .addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorCount >> 3\\\" is a gas efficient division by 8 \\\"selectorCount / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n LibDiamond.initializeDiamondCut(_init, _calldata);\\n }\\n}\\n\",\"keccak256\":\"0x8cfd33aae7e3c4209777364ce776d944511d6110223c3f03f2e7a6ed4646d8cc\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n enum FacetCutAction {\\n Add,\\n Replace,\\n Remove\\n }\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external;\\n\\n event DiamondCut(FacetCut[] diamondCut, address init, bytes callData);\\n}\\n\",\"keccak256\":\"0x6a3129be1f39b6fec871f2c94bf7debf2d6a4e665547a4d83e7f2def38359e44\",\"license\":\"MIT\"},\"contracts/libraries/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // maps function selectors to the facets that execute the functions.\\n // and maps the selectors to their position in the selectorSlots array.\\n // func selector => address facet, selector position\\n mapping(bytes4 => bytes32) facets;\\n // array of slots of function selectors.\\n // each slot holds 8 function selectors.\\n mapping(uint256 => bytes32) selectorSlots;\\n // The number of function selectors in selectorSlots\\n uint16 selectorCount;\\n // Used to query if a contract implements an interface.\\n // Used to implement ERC-165.\\n mapping(bytes4 => bool) supportedInterfaces;\\n // owner of the contract\\n address contractOwner;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n require(\\n msg.sender == diamondStorage().contractOwner,\\n \\\"LibDiamond: Must be contract owner\\\"\\n );\\n }\\n\\n event DiamondCut(\\n IDiamondCut.FacetCut[] diamondCut,\\n address init,\\n bytes callData\\n );\\n\\n bytes32 constant CLEAR_ADDRESS_MASK =\\n bytes32(uint256(0xffffffffffffffffffffffff));\\n bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));\\n\\n // Internal function version of diamondCut\\n // This code is almost the same as the external diamondCut,\\n // except it is using 'Facet[] memory _diamondCut' instead of\\n // 'Facet[] calldata _diamondCut'.\\n // The code is duplicated to prevent copying calldata to memory which\\n // causes an error for a two dimensional array.\\n function diamondCut(\\n IDiamondCut.FacetCut[] memory _diamondCut,\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addReplaceRemoveFacetSelectors(\\n uint256 _selectorCount,\\n bytes32 _selectorSlot,\\n address _newFacetAddress,\\n IDiamondCut.FacetCutAction _action,\\n bytes4[] memory _selectors\\n ) internal returns (uint256, bytes32) {\\n DiamondStorage storage ds = diamondStorage();\\n require(\\n _selectors.length > 0,\\n \\\"LibDiamondCut: No selectors in facet to cut\\\"\\n );\\n if (_action == IDiamondCut.FacetCutAction.Add) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Add facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) == address(0),\\n \\\"LibDiamondCut: Can't add function that already exists\\\"\\n );\\n // add facet for selector\\n ds.facets[selector] =\\n bytes20(_newFacetAddress) |\\n bytes32(_selectorCount);\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;\\n // clear selector position in slot and add selector\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |\\n (bytes32(selector) >> selectorInSlotPosition);\\n // if slot is full then write it to storage\\n if (selectorInSlotPosition == 224) {\\n // \\\"_selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"_selectorSlot / 8\\\"\\n ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;\\n _selectorSlot = 0;\\n }\\n _selectorCount++;\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Replace) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Replace facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n address oldFacetAddress = address(bytes20(oldFacet));\\n // only useful if immutable functions exist\\n require(\\n oldFacetAddress != address(this),\\n \\\"LibDiamondCut: Can't replace immutable function\\\"\\n );\\n require(\\n oldFacetAddress != _newFacetAddress,\\n \\\"LibDiamondCut: Can't replace function with same function\\\"\\n );\\n require(\\n oldFacetAddress != address(0),\\n \\\"LibDiamondCut: Can't replace function that doesn't exist\\\"\\n );\\n // replace old facet address\\n ds.facets[selector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(_newFacetAddress);\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Remove) {\\n require(\\n _newFacetAddress == address(0),\\n \\\"LibDiamondCut: Remove facet address must be address(0)\\\"\\n );\\n // \\\"_selectorCount >> 3\\\" is a gas efficient division by 8 \\\"_selectorCount / 8\\\"\\n uint256 selectorSlotCount = _selectorCount >> 3;\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotIndex = _selectorCount & 7;\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n if (_selectorSlot == 0) {\\n // get last selectorSlot\\n selectorSlotCount--;\\n _selectorSlot = ds.selectorSlots[selectorSlotCount];\\n selectorInSlotIndex = 7;\\n } else {\\n selectorInSlotIndex--;\\n }\\n bytes4 lastSelector;\\n uint256 oldSelectorsSlotCount;\\n uint256 oldSelectorInSlotPosition;\\n // adding a block here prevents stack too deep error\\n {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) != address(0),\\n \\\"LibDiamondCut: Can't remove function that doesn't exist\\\"\\n );\\n // only useful if immutable functions exist\\n require(\\n address(bytes20(oldFacet)) != address(this),\\n \\\"LibDiamondCut: Can't remove immutable function\\\"\\n );\\n // replace selector with last selector in ds.facets\\n // gets the last selector\\n lastSelector = bytes4(\\n _selectorSlot << (selectorInSlotIndex << 5)\\n );\\n if (lastSelector != selector) {\\n // update last selector slot position info\\n ds.facets[lastSelector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(ds.facets[lastSelector]);\\n }\\n delete ds.facets[selector];\\n uint256 oldSelectorCount = uint16(uint256(oldFacet));\\n // \\\"oldSelectorCount >> 3\\\" is a gas efficient division by 8 \\\"oldSelectorCount / 8\\\"\\n oldSelectorsSlotCount = oldSelectorCount >> 3;\\n // \\\"oldSelectorCount & 7\\\" is a gas efficient modulo by eight \\\"oldSelectorCount % 8\\\"\\n oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;\\n }\\n if (oldSelectorsSlotCount != selectorSlotCount) {\\n bytes32 oldSelectorSlot = ds.selectorSlots[\\n oldSelectorsSlotCount\\n ];\\n // clears the selector we are deleting and puts the last selector in its place.\\n oldSelectorSlot =\\n (oldSelectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n // update storage with the modified slot\\n ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;\\n } else {\\n // clears the selector we are deleting and puts the last selector in its place.\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n }\\n if (selectorInSlotIndex == 0) {\\n delete ds.selectorSlots[selectorSlotCount];\\n _selectorSlot = 0;\\n }\\n }\\n _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;\\n } else {\\n revert(\\\"LibDiamondCut: Incorrect FacetCutAction\\\");\\n }\\n return (_selectorCount, _selectorSlot);\\n }\\n\\n function initializeDiamondCut(\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n if (_init == address(0)) {\\n require(\\n _calldata.length == 0,\\n \\\"LibDiamondCut: _init is address(0) but_calldata is not empty\\\"\\n );\\n } else {\\n require(\\n _calldata.length > 0,\\n \\\"LibDiamondCut: _calldata is empty but _init is not address(0)\\\"\\n );\\n if (_init != address(this)) {\\n enforceHasContractCode(\\n _init,\\n \\\"LibDiamondCut: _init address has no code\\\"\\n );\\n }\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up the error\\n revert(string(error));\\n } else {\\n revert(\\\"LibDiamondCut: _init function reverted\\\");\\n }\\n }\\n }\\n }\\n\\n function enforceHasContractCode(\\n address _contract,\\n string memory _errorMessage\\n ) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n require(contractSize > 0, _errorMessage);\\n }\\n}\\n\",\"keccak256\":\"0x581eb846bee3d62731f4fc5bf21aa9cf744f491075941de685797f107e5d06f2\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061125e806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004610d90565b610045565b005b61004d61027b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9061ffff8116908190600090600716156100bc5750600381901c60009081526001840160205260409020545b60005b888110156101b35761019c83838c8c858181106100de576100de610e42565b90506020028101906100f09190610e58565b6100fe906020810190610e78565b8d8d8681811061011057610110610e42565b90506020028101906101229190610e58565b610133906040810190602001610ea9565b8e8e8781811061014557610145610e42565b90506020028101906101579190610e58565b610165906040810190610ec4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061030992505050565b9093509150806101ab81610f24565b9150506100bf565b508282146101cf5760028401805461ffff191661ffff84161790555b60078216156101f157600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738989898989604051610228959493929190610fcc565b60405180910390a16102708787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610af792505050565b505050505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146103075760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b60648201526084015b60405180910390fd5b565b600080807fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c905060008451116103955760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084016102fe565b60008560028111156103a9576103a9610f3d565b03610516576103d0866040518060600160405280602481526020016111b560249139610d0a565b60005b84518110156105105760008582815181106103f0576103f0610e42565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c156104895760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b60648201526084016102fe565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036104ed5760038c901c600090815260018601602052604081209b909b555b8b6104f781610f24565b9c5050505050808061050890610f24565b9150506103d3565b50610aeb565b600185600281111561052a5761052a610f3d565b03610759576105518660405180606001604052806028815260200161120160289139610d0a565b60005b845181101561051057600085828151811061057157610571610e42565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c3081036106065760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b60648201526084016102fe565b896001600160a01b0316816001600160a01b03160361068d5760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060648201526084016102fe565b6001600160a01b0381166107095760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e2774206578697374000000000000000060648201526084016102fe565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b161790558061075181610f24565b915050610554565b600285600281111561076d5761076d610f3d565b03610a93576001600160a01b038616156107e85760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b60648201526084016102fe565b600388901c6007891660005b8651811015610a735760008a90036108305782610810816110f5565b60008181526001870160205260409020549b5093506007925061083e9050565b8161083a816110f5565b9250505b6000806000808a858151811061085657610856610e42565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6108f65760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e277420657869737400000000000000000060648201526084016102fe565b30606082901c036109605760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b60648201526084016102fe565b600587901b8f901b94506001600160e01b0319808616908316146109b6576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214610a1b576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c179055610a3f565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b84600003610a5d57600086815260018801602052604081208190559c505b5050508080610a6b90610f24565b9150506107f4565b5080610a8083600861110c565b610a8a919061112b565b99505050610aeb565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b60648201526084016102fe565b50959694955050505050565b6001600160a01b038216610b7e57805115610b7a5760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d7074790000000060648201526084016102fe565b5050565b6000815111610bf55760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f74206164647265737328302900000060648201526084016102fe565b6001600160a01b0382163014610c2757610c27826040518060600160405280602881526020016111d960289139610d0a565b600080836001600160a01b031683604051610c42919061116f565b600060405180830381855af49150503d8060008114610c7d576040519150601f19603f3d011682016040523d82523d6000602084013e610c82565b606091505b509150915081610d0457805115610cad578060405162461bcd60e51b81526004016102fe9190611181565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b60648201526084016102fe565b50505050565b813b8181610d045760405162461bcd60e51b81526004016102fe9190611181565b80356001600160a01b0381168114610d4257600080fd5b919050565b60008083601f840112610d5957600080fd5b50813567ffffffffffffffff811115610d7157600080fd5b602083019150836020828501011115610d8957600080fd5b9250929050565b600080600080600060608688031215610da857600080fd5b853567ffffffffffffffff80821115610dc057600080fd5b818801915088601f830112610dd457600080fd5b813581811115610de357600080fd5b8960208260051b8501011115610df857600080fd5b60208301975080965050610e0e60208901610d2b565b94506040880135915080821115610e2457600080fd5b50610e3188828901610d47565b969995985093965092949392505050565b634e487b7160e01b600052603260045260246000fd5b60008235605e19833603018112610e6e57600080fd5b9190910192915050565b600060208284031215610e8a57600080fd5b610e9382610d2b565b9392505050565b803560038110610d4257600080fd5b600060208284031215610ebb57600080fd5b610e9382610e9a565b6000808335601e19843603018112610edb57600080fd5b83018035915067ffffffffffffffff821115610ef657600080fd5b6020019150600581901b3603821315610d8957600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610f3657610f36610f0e565b5060010190565b634e487b7160e01b600052602160045260246000fd5b818352600060208085019450826000805b86811015610f975782356001600160e01b03198116808214610f84578384fd5b8952509683019691830191600101610f64565b50959695505050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6060808252818101869052600090600560808085019089831b8601018a855b8b8110156110c257878303607f190184528135368e9003605e1901811261101157600080fd5b8d016001600160a01b0361102482610d2b565b1684526020611034818301610e9a565b6003811061105257634e487b7160e01b600052602160045260246000fd5b8582015260408281013536849003601e1901811261106f57600080fd5b8301803567ffffffffffffffff81111561108857600080fd5b808a1b360385131561109957600080fd5b8a838901526110ad8b890182868501610f53565b98840198975050509301925050600101610feb565b50506001600160a01b038916602087015285810360408701526110e681888a610fa3565b9b9a5050505050505050505050565b60008161110457611104610f0e565b506000190190565b600081600019048311821515161561112657611126610f0e565b500290565b6000821982111561113e5761113e610f0e565b500190565b60005b8381101561115e578181015183820152602001611146565b83811115610d045750506000910152565b60008251610e6e818460208701611143565b60208152600082518060208401526111a0816040850160208701611143565b601f01601f1916919091016040019291505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122028861677406609588a7a33a9c38e767246f8fdbbbb783c2eb6d3bd23f64a309664736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631f931c1c14610030575b600080fd5b61004361003e366004610d90565b610045565b005b61004d61027b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e547fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9061ffff8116908190600090600716156100bc5750600381901c60009081526001840160205260409020545b60005b888110156101b35761019c83838c8c858181106100de576100de610e42565b90506020028101906100f09190610e58565b6100fe906020810190610e78565b8d8d8681811061011057610110610e42565b90506020028101906101229190610e58565b610133906040810190602001610ea9565b8e8e8781811061014557610145610e42565b90506020028101906101579190610e58565b610165906040810190610ec4565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061030992505050565b9093509150806101ab81610f24565b9150506100bf565b508282146101cf5760028401805461ffff191661ffff84161790555b60078216156101f157600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738989898989604051610228959493929190610fcc565b60405180910390a16102708787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610af792505050565b505050505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146103075760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b60648201526084015b60405180910390fd5b565b600080807fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c905060008451116103955760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b60648201526084016102fe565b60008560028111156103a9576103a9610f3d565b03610516576103d0866040518060600160405280602481526020016111b560249139610d0a565b60005b84518110156105105760008582815181106103f0576103f0610e42565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c156104895760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f6044820152746e207468617420616c72656164792065786973747360581b60648201526084016102fe565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036104ed5760038c901c600090815260018601602052604081209b909b555b8b6104f781610f24565b9c5050505050808061050890610f24565b9150506103d3565b50610aeb565b600185600281111561052a5761052a610f3d565b03610759576105518660405180606001604052806028815260200161120160289139610d0a565b60005b845181101561051057600085828151811061057157610571610e42565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c3081036106065760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b60648201526084016102fe565b896001600160a01b0316816001600160a01b03160361068d5760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e000000000000000060648201526084016102fe565b6001600160a01b0381166107095760405162461bcd60e51b815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e207468617420646f65736e2774206578697374000000000000000060648201526084016102fe565b506001600160e01b031990911660009081526020849052604090206bffffffffffffffffffffffff919091166001600160601b031960608a901b161790558061075181610f24565b915050610554565b600285600281111561076d5761076d610f3d565b03610a93576001600160a01b038616156107e85760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f76652066616365742061646472604482015275657373206d757374206265206164647265737328302960501b60648201526084016102fe565b600388901c6007891660005b8651811015610a735760008a90036108305782610810816110f5565b60008181526001870160205260409020549b5093506007925061083e9050565b8161083a816110f5565b9250505b6000806000808a858151811061085657610856610e42565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c6108f65760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e277420657869737400000000000000000060648201526084016102fe565b30606082901c036109605760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b60648201526084016102fe565b600587901b8f901b94506001600160e01b0319808616908316146109b6576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166bffffffffffffffffffffffff83161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214610a1b576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c179055610a3f565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b84600003610a5d57600086815260018801602052604081208190559c505b5050508080610a6b90610f24565b9150506107f4565b5080610a8083600861110c565b610a8a919061112b565b99505050610aeb565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b60648201526084016102fe565b50959694955050505050565b6001600160a01b038216610b7e57805115610b7a5760405162461bcd60e51b815260206004820152603c60248201527f4c69624469616d6f6e644375743a205f696e697420697320616464726573732860448201527f3029206275745f63616c6c64617461206973206e6f7420656d7074790000000060648201526084016102fe565b5050565b6000815111610bf55760405162461bcd60e51b815260206004820152603d60248201527f4c69624469616d6f6e644375743a205f63616c6c6461746120697320656d707460448201527f7920627574205f696e6974206973206e6f74206164647265737328302900000060648201526084016102fe565b6001600160a01b0382163014610c2757610c27826040518060600160405280602881526020016111d960289139610d0a565b600080836001600160a01b031683604051610c42919061116f565b600060405180830381855af49150503d8060008114610c7d576040519150601f19603f3d011682016040523d82523d6000602084013e610c82565b606091505b509150915081610d0457805115610cad578060405162461bcd60e51b81526004016102fe9190611181565b60405162461bcd60e51b815260206004820152602660248201527f4c69624469616d6f6e644375743a205f696e69742066756e6374696f6e2072656044820152651d995c9d195960d21b60648201526084016102fe565b50505050565b813b8181610d045760405162461bcd60e51b81526004016102fe9190611181565b80356001600160a01b0381168114610d4257600080fd5b919050565b60008083601f840112610d5957600080fd5b50813567ffffffffffffffff811115610d7157600080fd5b602083019150836020828501011115610d8957600080fd5b9250929050565b600080600080600060608688031215610da857600080fd5b853567ffffffffffffffff80821115610dc057600080fd5b818801915088601f830112610dd457600080fd5b813581811115610de357600080fd5b8960208260051b8501011115610df857600080fd5b60208301975080965050610e0e60208901610d2b565b94506040880135915080821115610e2457600080fd5b50610e3188828901610d47565b969995985093965092949392505050565b634e487b7160e01b600052603260045260246000fd5b60008235605e19833603018112610e6e57600080fd5b9190910192915050565b600060208284031215610e8a57600080fd5b610e9382610d2b565b9392505050565b803560038110610d4257600080fd5b600060208284031215610ebb57600080fd5b610e9382610e9a565b6000808335601e19843603018112610edb57600080fd5b83018035915067ffffffffffffffff821115610ef657600080fd5b6020019150600581901b3603821315610d8957600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610f3657610f36610f0e565b5060010190565b634e487b7160e01b600052602160045260246000fd5b818352600060208085019450826000805b86811015610f975782356001600160e01b03198116808214610f84578384fd5b8952509683019691830191600101610f64565b50959695505050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6060808252818101869052600090600560808085019089831b8601018a855b8b8110156110c257878303607f190184528135368e9003605e1901811261101157600080fd5b8d016001600160a01b0361102482610d2b565b1684526020611034818301610e9a565b6003811061105257634e487b7160e01b600052602160045260246000fd5b8582015260408281013536849003601e1901811261106f57600080fd5b8301803567ffffffffffffffff81111561108857600080fd5b808a1b360385131561109957600080fd5b8a838901526110ad8b890182868501610f53565b98840198975050509301925050600101610feb565b50506001600160a01b038916602087015285810360408701526110e681888a610fa3565b9b9a5050505050505050505050565b60008161110457611104610f0e565b506000190190565b600081600019048311821515161561112657611126610f0e565b500290565b6000821982111561113e5761113e610f0e565b500190565b60005b8381101561115e578181015183820152602001611146565b83811115610d045750506000910152565b60008251610e6e818460208701611143565b60208152600082518060208401526111a0816040850160208701611143565b601f01601f1916919091016040019291505056fe4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a264697066735822122028861677406609588a7a33a9c38e767246f8fdbbbb783c2eb6d3bd23f64a309664736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "diamondCut((address,uint8,bytes4[])[],address,bytes)": { + "params": { + "_calldata": "A function call, including function selector and arguments _calldata is executed with delegatecall on _init", + "_diamondCut": "Contains the facet addresses and function selectors", + "_init": "The address of the contract or facet to execute _calldata" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "diamondCut((address,uint8,bytes4[])[],address,bytes)": { + "notice": "Add/replace/remove any number of functions and optionally execute a function with delegatecall" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/DiamondInit.json b/onchain/rollups/deployments/gnosis_chiado/DiamondInit.json new file mode 100644 index 00000000..78fc4d62 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/DiamondInit.json @@ -0,0 +1,173 @@ +{ + "address": "0xCbEDAB3193dc8027cc403a01cE054695a08E2F34", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "feeManagerBank", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + } + ], + "name": "FeeManagerInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + } + ], + "name": "RollupsInitialized", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerBank", + "type": "address" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "internalType": "struct DiamondConfig", + "name": "_dConfig", + "type": "tuple" + } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x4c46cae41f0ecf38925b219aad7ed1445a7804545e2e7e785d2e7190cd70728c", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "645412", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x500fecd12bd0340c8ce057c440b2fe39f895da8f1a09d92df9a9037d9bf3849d", + "transactionHash": "0x4c46cae41f0ecf38925b219aad7ed1445a7804545e2e7e785d2e7190cd70728c", + "logs": [], + "blockNumber": 1143576, + "cumulativeGasUsed": "645412", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"feePerClaim\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeManagerBank\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"feeManagerOwner\",\"type\":\"address\"}],\"name\":\"FeeManagerInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"inputDuration\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"challengePeriod\",\"type\":\"uint256\"}],\"name\":\"RollupsInitialized\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"templateHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"inputDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"challengePeriod\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputLog2Size\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"feePerClaim\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeManagerBank\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeManagerOwner\",\"type\":\"address\"},{\"internalType\":\"address payable[]\",\"name\":\"validators\",\"type\":\"address[]\"}],\"internalType\":\"struct DiamondConfig\",\"name\":\"_dConfig\",\"type\":\"tuple\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"FeeManagerInitialized(uint256,address,address)\":{\"params\":{\"feeManagerBank\":\"fee manager bank address\",\"feeManagerOwner\":\"fee manager owner address\",\"feePerClaim\":\"fee per claim to reward the validators\"}},\"RollupsInitialized(uint256,uint256)\":{\"params\":{\"challengePeriod\":\"duration of challenge period in seconds\",\"inputDuration\":\"duration of input accumulation phase in seconds\"}}},\"kind\":\"dev\",\"methods\":{\"init((bytes32,uint256,uint256,uint256,uint256,address,address,address[]))\":{\"params\":{\"_dConfig\":\"diamond configurations\"}}},\"version\":1},\"userdoc\":{\"events\":{\"FeeManagerInitialized(uint256,address,address)\":{\"notice\":\"FeeManagerImpl contract initialized\"},\"RollupsInitialized(uint256,uint256)\":{\"notice\":\"rollups contract initialized\"}},\"kind\":\"user\",\"methods\":{\"init((bytes32,uint256,uint256,uint256,uint256,address,address,address[]))\":{\"notice\":\"initialize the diamond\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/upgrade_initializers/DiamondInit.sol\":\"DiamondInit\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n enum FacetCutAction {\\n Add,\\n Replace,\\n Remove\\n }\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external;\\n\\n event DiamondCut(FacetCut[] diamondCut, address init, bytes callData);\\n}\\n\",\"keccak256\":\"0x6a3129be1f39b6fec871f2c94bf7debf2d6a4e665547a4d83e7f2def38359e44\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(\\n address _facet\\n ) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses()\\n external\\n view\\n returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(\\n bytes4 _functionSelector\\n ) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0xdc5991b0218ab6b2cd78983c19f74a789a79ec9a9ba756ae05c8dcd512c13e38\",\"license\":\"MIT\"},\"contracts/interfaces/IERC173.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/// @title ERC-173 Contract Ownership Standard\\n/// Note: the ERC-165 identifier for this interface is 0x7f5828d0\\n/* is ERC165 */\\ninterface IERC173 {\\n /// @dev This emits when ownership of a contract changes.\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n /// @notice Get the address of the owner\\n /// @return owner_ The address of the owner.\\n function owner() external view returns (address owner_);\\n\\n /// @notice Set the address of the new owner of the contract\\n /// @dev Set _newOwner to address(0) to renounce any ownership.\\n /// @param _newOwner The address of the new owner of the contract\\n function transferOwnership(address _newOwner) external;\\n}\\n\",\"keccak256\":\"0xc47289cda9c9cdb749612eb82ccb9abf9ab08dca74bdca22292ae7f765a15a5f\",\"license\":\"MIT\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // maps function selectors to the facets that execute the functions.\\n // and maps the selectors to their position in the selectorSlots array.\\n // func selector => address facet, selector position\\n mapping(bytes4 => bytes32) facets;\\n // array of slots of function selectors.\\n // each slot holds 8 function selectors.\\n mapping(uint256 => bytes32) selectorSlots;\\n // The number of function selectors in selectorSlots\\n uint16 selectorCount;\\n // Used to query if a contract implements an interface.\\n // Used to implement ERC-165.\\n mapping(bytes4 => bool) supportedInterfaces;\\n // owner of the contract\\n address contractOwner;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n require(\\n msg.sender == diamondStorage().contractOwner,\\n \\\"LibDiamond: Must be contract owner\\\"\\n );\\n }\\n\\n event DiamondCut(\\n IDiamondCut.FacetCut[] diamondCut,\\n address init,\\n bytes callData\\n );\\n\\n bytes32 constant CLEAR_ADDRESS_MASK =\\n bytes32(uint256(0xffffffffffffffffffffffff));\\n bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));\\n\\n // Internal function version of diamondCut\\n // This code is almost the same as the external diamondCut,\\n // except it is using 'Facet[] memory _diamondCut' instead of\\n // 'Facet[] calldata _diamondCut'.\\n // The code is duplicated to prevent copying calldata to memory which\\n // causes an error for a two dimensional array.\\n function diamondCut(\\n IDiamondCut.FacetCut[] memory _diamondCut,\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addReplaceRemoveFacetSelectors(\\n uint256 _selectorCount,\\n bytes32 _selectorSlot,\\n address _newFacetAddress,\\n IDiamondCut.FacetCutAction _action,\\n bytes4[] memory _selectors\\n ) internal returns (uint256, bytes32) {\\n DiamondStorage storage ds = diamondStorage();\\n require(\\n _selectors.length > 0,\\n \\\"LibDiamondCut: No selectors in facet to cut\\\"\\n );\\n if (_action == IDiamondCut.FacetCutAction.Add) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Add facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) == address(0),\\n \\\"LibDiamondCut: Can't add function that already exists\\\"\\n );\\n // add facet for selector\\n ds.facets[selector] =\\n bytes20(_newFacetAddress) |\\n bytes32(_selectorCount);\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;\\n // clear selector position in slot and add selector\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |\\n (bytes32(selector) >> selectorInSlotPosition);\\n // if slot is full then write it to storage\\n if (selectorInSlotPosition == 224) {\\n // \\\"_selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"_selectorSlot / 8\\\"\\n ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;\\n _selectorSlot = 0;\\n }\\n _selectorCount++;\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Replace) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Replace facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n address oldFacetAddress = address(bytes20(oldFacet));\\n // only useful if immutable functions exist\\n require(\\n oldFacetAddress != address(this),\\n \\\"LibDiamondCut: Can't replace immutable function\\\"\\n );\\n require(\\n oldFacetAddress != _newFacetAddress,\\n \\\"LibDiamondCut: Can't replace function with same function\\\"\\n );\\n require(\\n oldFacetAddress != address(0),\\n \\\"LibDiamondCut: Can't replace function that doesn't exist\\\"\\n );\\n // replace old facet address\\n ds.facets[selector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(_newFacetAddress);\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Remove) {\\n require(\\n _newFacetAddress == address(0),\\n \\\"LibDiamondCut: Remove facet address must be address(0)\\\"\\n );\\n // \\\"_selectorCount >> 3\\\" is a gas efficient division by 8 \\\"_selectorCount / 8\\\"\\n uint256 selectorSlotCount = _selectorCount >> 3;\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotIndex = _selectorCount & 7;\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n if (_selectorSlot == 0) {\\n // get last selectorSlot\\n selectorSlotCount--;\\n _selectorSlot = ds.selectorSlots[selectorSlotCount];\\n selectorInSlotIndex = 7;\\n } else {\\n selectorInSlotIndex--;\\n }\\n bytes4 lastSelector;\\n uint256 oldSelectorsSlotCount;\\n uint256 oldSelectorInSlotPosition;\\n // adding a block here prevents stack too deep error\\n {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) != address(0),\\n \\\"LibDiamondCut: Can't remove function that doesn't exist\\\"\\n );\\n // only useful if immutable functions exist\\n require(\\n address(bytes20(oldFacet)) != address(this),\\n \\\"LibDiamondCut: Can't remove immutable function\\\"\\n );\\n // replace selector with last selector in ds.facets\\n // gets the last selector\\n lastSelector = bytes4(\\n _selectorSlot << (selectorInSlotIndex << 5)\\n );\\n if (lastSelector != selector) {\\n // update last selector slot position info\\n ds.facets[lastSelector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(ds.facets[lastSelector]);\\n }\\n delete ds.facets[selector];\\n uint256 oldSelectorCount = uint16(uint256(oldFacet));\\n // \\\"oldSelectorCount >> 3\\\" is a gas efficient division by 8 \\\"oldSelectorCount / 8\\\"\\n oldSelectorsSlotCount = oldSelectorCount >> 3;\\n // \\\"oldSelectorCount & 7\\\" is a gas efficient modulo by eight \\\"oldSelectorCount % 8\\\"\\n oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;\\n }\\n if (oldSelectorsSlotCount != selectorSlotCount) {\\n bytes32 oldSelectorSlot = ds.selectorSlots[\\n oldSelectorsSlotCount\\n ];\\n // clears the selector we are deleting and puts the last selector in its place.\\n oldSelectorSlot =\\n (oldSelectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n // update storage with the modified slot\\n ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;\\n } else {\\n // clears the selector we are deleting and puts the last selector in its place.\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n }\\n if (selectorInSlotIndex == 0) {\\n delete ds.selectorSlots[selectorSlotCount];\\n _selectorSlot = 0;\\n }\\n }\\n _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;\\n } else {\\n revert(\\\"LibDiamondCut: Incorrect FacetCutAction\\\");\\n }\\n return (_selectorCount, _selectorSlot);\\n }\\n\\n function initializeDiamondCut(\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n if (_init == address(0)) {\\n require(\\n _calldata.length == 0,\\n \\\"LibDiamondCut: _init is address(0) but_calldata is not empty\\\"\\n );\\n } else {\\n require(\\n _calldata.length > 0,\\n \\\"LibDiamondCut: _calldata is empty but _init is not address(0)\\\"\\n );\\n if (_init != address(this)) {\\n enforceHasContractCode(\\n _init,\\n \\\"LibDiamondCut: _init address has no code\\\"\\n );\\n }\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up the error\\n revert(string(error));\\n } else {\\n revert(\\\"LibDiamondCut: _init function reverted\\\");\\n }\\n }\\n }\\n }\\n\\n function enforceHasContractCode(\\n address _contract,\\n string memory _errorMessage\\n ) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n require(contractSize > 0, _errorMessage);\\n }\\n}\\n\",\"keccak256\":\"0x581eb846bee3d62731f4fc5bf21aa9cf744f491075941de685797f107e5d06f2\",\"license\":\"MIT\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"},\"contracts/upgrade_initializers/DiamondInit.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Diamond Initialization Contract\\npragma solidity ^0.8.0;\\n\\n// Rollups-related dependencies\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\n// Diamond-related dependencies\\nimport {LibDiamond} from \\\"../libraries/LibDiamond.sol\\\";\\nimport {IDiamondLoupe} from \\\"../interfaces/IDiamondLoupe.sol\\\";\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\nimport {IERC173} from \\\"../interfaces/IERC173.sol\\\"; // not in openzeppelin-contracts yet\\nimport {IERC165} from \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\n/// @notice diamond configurations\\n/// @param templateHash state hash of the cartesi machine at t0\\n/// @param inputDuration duration of input accumulation phase in seconds\\n/// @param challengePeriod duration of challenge period in seconds\\n/// @param inputLog2Size size of the input memory range in this machine\\n/// @param feePerClaim fee per claim to reward the validators\\n/// @param feeManagerBank fee manager bank address\\n/// @param feeManagerOwner fee manager owner address\\n/// @param validators initial validator set\\n/// @dev validators have to be unique, if the same validator is added twice\\n/// consensus will never be reached\\nstruct DiamondConfig {\\n // RollupsFacet\\n bytes32 templateHash;\\n uint256 inputDuration;\\n uint256 challengePeriod;\\n // InputFacet\\n uint256 inputLog2Size;\\n // FeeManagerFacet\\n uint256 feePerClaim;\\n address feeManagerBank;\\n address feeManagerOwner;\\n // ValidatorManagerFacet\\n address payable[] validators;\\n}\\n\\ncontract DiamondInit {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibInput for LibInput.DiamondStorage;\\n\\n /// @notice initialize the diamond\\n /// @param _dConfig diamond configurations\\n function init(DiamondConfig calldata _dConfig) external {\\n initERC165();\\n initValidatorManager(_dConfig.validators);\\n initRollups(\\n _dConfig.templateHash,\\n _dConfig.inputDuration,\\n _dConfig.challengePeriod\\n );\\n initFeeManager(\\n _dConfig.feePerClaim,\\n _dConfig.feeManagerBank,\\n _dConfig.feeManagerOwner\\n );\\n initInput(_dConfig.inputLog2Size);\\n }\\n\\n /// @notice initialize ERC165 data\\n function initERC165() private {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n ds.supportedInterfaces[type(IERC165).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;\\n ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;\\n ds.supportedInterfaces[type(IERC173).interfaceId] = true;\\n }\\n\\n /// @notice initalize the Input facet\\n /// @param _inputLog2Size size of the input memory range in this machine\\n function initInput(uint256 _inputLog2Size) private {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n\\n require(\\n _inputLog2Size >= 3 && _inputLog2Size <= 64,\\n \\\"Log of input size: [3,64]\\\"\\n );\\n\\n inputDS.inputDriveSize = (1 << _inputLog2Size);\\n\\n // input box gets initialized with one empty input\\n // so that the L2 DApp knows it's own address\\n inputDS.addInternalInput(\\\"\\\");\\n }\\n\\n /// @notice initialize the Validator Manager facet\\n /// @param _validators initial validator set\\n function initValidatorManager(\\n address payable[] memory _validators\\n ) private {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n uint256 maxNumValidators = _validators.length;\\n\\n require(maxNumValidators <= 8, \\\"up to 8 validators\\\");\\n\\n validatorManagerDS.validators = _validators;\\n validatorManagerDS.maxNumValidators = maxNumValidators;\\n\\n // create a new ClaimsMask, with only the consensus goal set,\\n // according to the number of validators\\n validatorManagerDS.claimsMask = LibClaimsMask\\n .newClaimsMaskWithConsensusGoalSet(maxNumValidators);\\n }\\n\\n /// @notice rollups contract initialized\\n /// @param inputDuration duration of input accumulation phase in seconds\\n /// @param challengePeriod duration of challenge period in seconds\\n event RollupsInitialized(uint256 inputDuration, uint256 challengePeriod);\\n\\n /// @notice initialize the Rollups facet\\n /// @param _templateHash state hash of the cartesi machine at t0\\n /// @param _inputDuration duration of input accumulation phase in seconds\\n /// @param _challengePeriod duration of challenge period in seconds\\n function initRollups(\\n bytes32 _templateHash,\\n uint256 _inputDuration,\\n uint256 _challengePeriod\\n ) private {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n rollupsDS.templateHash = _templateHash;\\n rollupsDS.inputDuration = uint32(_inputDuration);\\n rollupsDS.challengePeriod = uint32(_challengePeriod);\\n rollupsDS.inputAccumulationStart = uint32(block.timestamp);\\n rollupsDS.currentPhase_int = uint32(Phase.InputAccumulation);\\n\\n emit RollupsInitialized(_inputDuration, _challengePeriod);\\n }\\n\\n /// @notice FeeManagerImpl contract initialized\\n /// @param feePerClaim fee per claim to reward the validators\\n /// @param feeManagerBank fee manager bank address\\n /// @param feeManagerOwner fee manager owner address\\n event FeeManagerInitialized(\\n uint256 feePerClaim,\\n address feeManagerBank,\\n address feeManagerOwner\\n );\\n\\n /// @notice initalize the Fee Manager facet\\n /// @param _feePerClaim fee per claim to reward the validators\\n /// @param _feeManagerBank fee manager bank address\\n /// @param _feeManagerOwner fee manager owner address\\n function initFeeManager(\\n uint256 _feePerClaim,\\n address _feeManagerBank,\\n address _feeManagerOwner\\n ) private {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n\\n feeManagerDS.feePerClaim = _feePerClaim;\\n feeManagerDS.bank = IBank(_feeManagerBank);\\n feeManagerDS.owner = _feeManagerOwner;\\n\\n emit FeeManagerInitialized(\\n _feePerClaim,\\n _feeManagerBank,\\n _feeManagerOwner\\n );\\n }\\n}\\n\",\"keccak256\":\"0xab936fa5e183f87bb4421ea393b10d37eaf0ab648ad6f0d8d6be49d545a0b644\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610ab1806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063af52770114610030575b600080fd5b61004361003e3660046108d6565b610045565b005b6101267fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f8054600160ff1991821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790556307f5828d60e41b6000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c380549091169091179055565b61016d61013660e0830183610912565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506101be92505050565b610181813560208301356040840135610260565b6101ae608082013561019960c0840160a08501610963565b6101a960e0850160c08601610963565b610339565b6101bb8160600135610407565b50565b80517f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fc90600881111561022d5760405162461bcd60e51b8152602060048201526012602482015271757020746f20382076616c696461746f727360701b60448201526064015b60405180910390fd5b8251610242906001840190602086019061085c565b5060028201819055610253816104ae565b8260030181905550505050565b7fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c8381557fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189d805463ffffffff8481166401000000000267ffffffffffffffff19909216868216179190911773ffffffff00000000ffffffff0000000000000000191642909116600160401b0263ffffffff60801b191617905560408051848152602081018490527fd6f5a5cd17f05cf9045751ee10f662f62e569c9371ffec8380510aabe63012d391015b60405180910390a150505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc748390557f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7580546001600160a01b038481166001600160a01b031992831681179093557f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7380549185169190921681178255604080518781526020810194909452830152907f5b54873359173c3d639e39928ad34e113039ce7c799d500e57f8a2c703adb4779060600161032b565b7f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6003821080159061043a575060408211155b6104865760405162461bcd60e51b815260206004820152601960248201527f4c6f67206f6620696e7075742073697a653a205b332c36345d000000000000006044820152606401610224565b6001821b60028201556040805160208101909152600081526104a990829061050f565b505050565b600060088211156104f65760405162461bcd60e51b8152602060048201526012602482015271757020746f20382076616c696461746f727360701b6044820152606401610224565b6000610505600180851b6109b8565b60f01b9392505050565b600061051c838330610523565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c91111561059d5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d00000000000000006044820152606401610224565b6105a6816106c8565b156105b4576105b48561079b565b600085600301546000146105cb57856001016105cd565b855b905060006105da836107ba565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161067f91906109b8565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516106b3939291906109cf565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156106f0576106f061098c565b600184015490915063ffffffff600160401b820481169116600083600281111561071c5761071c61098c565b148015610731575061072e8183610a3b565b42115b15610790576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f9161077d91610a53565b60405180910390a1506001949350505050565b506000949350505050565b6003810154156107ac5760006107af565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156108265761082661098c565b9050600081600281111561083c5761083c61098c565b146108515761084c826001610a3b565b610853565b815b95945050505050565b8280548282559060005260206000209081019282156108b1579160200282015b828111156108b157825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061087c565b506108bd9291506108c1565b5090565b5b808211156108bd57600081556001016108c2565b6000602082840312156108e857600080fd5b813567ffffffffffffffff8111156108ff57600080fd5b8201610100818503121561051c57600080fd5b6000808335601e1984360301811261092957600080fd5b83018035915067ffffffffffffffff82111561094457600080fd5b6020019150600581901b360382131561095c57600080fd5b9250929050565b60006020828403121561097557600080fd5b81356001600160a01b038116811461051c57600080fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000828210156109ca576109ca6109a2565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b81811015610a11578581018301518582016080015282016109f5565b81811115610a23576000608083870101525b50601f01601f19169290920160800195945050505050565b60008219821115610a4e57610a4e6109a2565b500190565b6020810160038310610a7557634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220ae9d04c8637c04ddcc005a0a84b4f6ff2b5c6c3077ebb1fe7cc418b79d79d4ef64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063af52770114610030575b600080fd5b61004361003e3660046108d6565b610045565b005b6101267fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f6020527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f8054600160ff1991821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790556307f5828d60e41b6000527f5622121b47b8cd0120c4efe45dd5483242f54a3d49bd7679be565d47694918c380549091169091179055565b61016d61013660e0830183610912565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506101be92505050565b610181813560208301356040840135610260565b6101ae608082013561019960c0840160a08501610963565b6101a960e0850160c08601610963565b610339565b6101bb8160600135610407565b50565b80517f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fc90600881111561022d5760405162461bcd60e51b8152602060048201526012602482015271757020746f20382076616c696461746f727360701b60448201526064015b60405180910390fd5b8251610242906001840190602086019061085c565b5060028201819055610253816104ae565b8260030181905550505050565b7fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c8381557fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189d805463ffffffff8481166401000000000267ffffffffffffffff19909216868216179190911773ffffffff00000000ffffffff0000000000000000191642909116600160401b0263ffffffff60801b191617905560408051848152602081018490527fd6f5a5cd17f05cf9045751ee10f662f62e569c9371ffec8380510aabe63012d391015b60405180910390a150505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc748390557f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7580546001600160a01b038481166001600160a01b031992831681179093557f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7380549185169190921681178255604080518781526020810194909452830152907f5b54873359173c3d639e39928ad34e113039ce7c799d500e57f8a2c703adb4779060600161032b565b7f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6003821080159061043a575060408211155b6104865760405162461bcd60e51b815260206004820152601960248201527f4c6f67206f6620696e7075742073697a653a205b332c36345d000000000000006044820152606401610224565b6001821b60028201556040805160208101909152600081526104a990829061050f565b505050565b600060088211156104f65760405162461bcd60e51b8152602060048201526012602482015271757020746f20382076616c696461746f727360701b6044820152606401610224565b6000610505600180851b6109b8565b60f01b9392505050565b600061051c838330610523565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c91111561059d5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d00000000000000006044820152606401610224565b6105a6816106c8565b156105b4576105b48561079b565b600085600301546000146105cb57856001016105cd565b855b905060006105da836107ba565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161067f91906109b8565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516106b3939291906109cf565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156106f0576106f061098c565b600184015490915063ffffffff600160401b820481169116600083600281111561071c5761071c61098c565b148015610731575061072e8183610a3b565b42115b15610790576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f9161077d91610a53565b60405180910390a1506001949350505050565b506000949350505050565b6003810154156107ac5760006107af565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156108265761082661098c565b9050600081600281111561083c5761083c61098c565b146108515761084c826001610a3b565b610853565b815b95945050505050565b8280548282559060005260206000209081019282156108b1579160200282015b828111156108b157825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061087c565b506108bd9291506108c1565b5090565b5b808211156108bd57600081556001016108c2565b6000602082840312156108e857600080fd5b813567ffffffffffffffff8111156108ff57600080fd5b8201610100818503121561051c57600080fd5b6000808335601e1984360301811261092957600080fd5b83018035915067ffffffffffffffff82111561094457600080fd5b6020019150600581901b360382131561095c57600080fd5b9250929050565b60006020828403121561097557600080fd5b81356001600160a01b038116811461051c57600080fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000828210156109ca576109ca6109a2565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b81811015610a11578581018301518582016080015282016109f5565b81811115610a23576000608083870101525b50601f01601f19169290920160800195945050505050565b60008219821115610a4e57610a4e6109a2565b500190565b6020810160038310610a7557634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220ae9d04c8637c04ddcc005a0a84b4f6ff2b5c6c3077ebb1fe7cc418b79d79d4ef64736f6c634300080d0033", + "devdoc": { + "events": { + "FeeManagerInitialized(uint256,address,address)": { + "params": { + "feeManagerBank": "fee manager bank address", + "feeManagerOwner": "fee manager owner address", + "feePerClaim": "fee per claim to reward the validators" + } + }, + "RollupsInitialized(uint256,uint256)": { + "params": { + "challengePeriod": "duration of challenge period in seconds", + "inputDuration": "duration of input accumulation phase in seconds" + } + } + }, + "kind": "dev", + "methods": { + "init((bytes32,uint256,uint256,uint256,uint256,address,address,address[]))": { + "params": { + "_dConfig": "diamond configurations" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "FeeManagerInitialized(uint256,address,address)": { + "notice": "FeeManagerImpl contract initialized" + }, + "RollupsInitialized(uint256,uint256)": { + "notice": "rollups contract initialized" + } + }, + "kind": "user", + "methods": { + "init((bytes32,uint256,uint256,uint256,uint256,address,address,address[]))": { + "notice": "initialize the diamond" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/DiamondLoupeFacet.json b/onchain/rollups/deployments/gnosis_chiado/DiamondLoupeFacet.json new file mode 100644 index 00000000..9febc218 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/DiamondLoupeFacet.json @@ -0,0 +1,177 @@ +{ + "address": "0x8339b06c37d488d51aB838f6C758D61ddb1F1C6c", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "facetFunctionSelectors_", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondLoupe.Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x977ecb458b72330c5d4f7242747363639d40859a01dd0c7e61744dda58bdff1b", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "670579", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xa4dc9047ff35e6bc7c4eb436b99f421f3237b629d372cb7798bf43a2f1a391a2", + "transactionHash": "0x977ecb458b72330c5d4f7242747363639d40859a01dd0c7e61744dda58bdff1b", + "logs": [], + "blockNumber": 1143554, + "cumulativeGasUsed": "670579", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_functionSelector\",\"type\":\"bytes4\"}],\"name\":\"facetAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"facetAddress_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"facetAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"facetAddresses_\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_facet\",\"type\":\"address\"}],\"name\":\"facetFunctionSelectors\",\"outputs\":[{\"internalType\":\"bytes4[]\",\"name\":\"facetFunctionSelectors_\",\"type\":\"bytes4[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"facets\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"facetAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4[]\",\"name\":\"functionSelectors\",\"type\":\"bytes4[]\"}],\"internalType\":\"struct IDiamondLoupe.Facet[]\",\"name\":\"facets_\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"_interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"facetAddress(bytes4)\":{\"details\":\"If facet is not found return address(0).\",\"params\":{\"_functionSelector\":\"The function selector.\"},\"returns\":{\"facetAddress_\":\"The facet address.\"}},\"facetAddresses()\":{\"returns\":{\"facetAddresses_\":\"facetAddresses_\"}},\"facetFunctionSelectors(address)\":{\"params\":{\"_facet\":\"The facet address.\"},\"returns\":{\"facetFunctionSelectors_\":\"The selectors associated with a facet address.\"}},\"facets()\":{\"returns\":{\"facets_\":\"Facet\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"facetAddress(bytes4)\":{\"notice\":\"Gets the facet that supports the given selector.\"},\"facetAddresses()\":{\"notice\":\"Get all the facet addresses used by a diamond.\"},\"facetFunctionSelectors(address)\":{\"notice\":\"Gets all the function selectors supported by a specific facet.\"},\"facets()\":{\"notice\":\"Gets all facets and their selectors.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/DiamondLoupeFacet.sol\":\"DiamondLoupeFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/facets/DiamondLoupeFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\nimport {LibDiamond} from \\\"../libraries/LibDiamond.sol\\\";\\nimport {IDiamondLoupe} from \\\"../interfaces/IDiamondLoupe.sol\\\";\\nimport {IERC165} from \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\n\\ncontract DiamondLoupeFacet is IDiamondLoupe, IERC165 {\\n // Diamond Loupe Functions\\n ////////////////////////////////////////////////////////////////////\\n /// These functions are expected to be called frequently by tools.\\n //\\n // struct Facet {\\n // address facetAddress;\\n // bytes4[] functionSelectors;\\n // }\\n\\n /// @notice Gets all facets and their selectors.\\n /// @return facets_ Facet\\n function facets() external view override returns (Facet[] memory facets_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n facets_ = new Facet[](ds.selectorCount);\\n uint8[] memory numFacetSelectors = new uint8[](ds.selectorCount);\\n uint256 numFacets;\\n uint256 selectorIndex;\\n // loop through function selectors\\n for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) {\\n bytes32 slot = ds.selectorSlots[slotIndex];\\n for (\\n uint256 selectorSlotIndex;\\n selectorSlotIndex < 8;\\n selectorSlotIndex++\\n ) {\\n selectorIndex++;\\n if (selectorIndex > ds.selectorCount) {\\n break;\\n }\\n bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));\\n address facetAddress_ = address(bytes20(ds.facets[selector]));\\n bool continueLoop;\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n if (facets_[facetIndex].facetAddress == facetAddress_) {\\n facets_[facetIndex].functionSelectors[\\n numFacetSelectors[facetIndex]\\n ] = selector;\\n // probably will never have more than 256 functions from one facet contract\\n require(numFacetSelectors[facetIndex] < 255);\\n numFacetSelectors[facetIndex]++;\\n continueLoop = true;\\n break;\\n }\\n }\\n if (continueLoop) {\\n continue;\\n }\\n facets_[numFacets].facetAddress = facetAddress_;\\n facets_[numFacets].functionSelectors = new bytes4[](\\n ds.selectorCount\\n );\\n facets_[numFacets].functionSelectors[0] = selector;\\n numFacetSelectors[numFacets] = 1;\\n numFacets++;\\n }\\n }\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n uint256 numSelectors = numFacetSelectors[facetIndex];\\n bytes4[] memory selectors = facets_[facetIndex].functionSelectors;\\n // setting the number of selectors\\n assembly {\\n mstore(selectors, numSelectors)\\n }\\n }\\n // setting the number of facets\\n assembly {\\n mstore(facets_, numFacets)\\n }\\n }\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_ The selectors associated with a facet address.\\n function facetFunctionSelectors(\\n address _facet\\n ) external view override returns (bytes4[] memory facetFunctionSelectors_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n uint256 numSelectors;\\n facetFunctionSelectors_ = new bytes4[](ds.selectorCount);\\n uint256 selectorIndex;\\n // loop through function selectors\\n for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) {\\n bytes32 slot = ds.selectorSlots[slotIndex];\\n for (\\n uint256 selectorSlotIndex;\\n selectorSlotIndex < 8;\\n selectorSlotIndex++\\n ) {\\n selectorIndex++;\\n if (selectorIndex > ds.selectorCount) {\\n break;\\n }\\n bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));\\n address facet = address(bytes20(ds.facets[selector]));\\n if (_facet == facet) {\\n facetFunctionSelectors_[numSelectors] = selector;\\n numSelectors++;\\n }\\n }\\n }\\n // Set the number of selectors in the array\\n assembly {\\n mstore(facetFunctionSelectors_, numSelectors)\\n }\\n }\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses()\\n external\\n view\\n override\\n returns (address[] memory facetAddresses_)\\n {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n facetAddresses_ = new address[](ds.selectorCount);\\n uint256 numFacets;\\n uint256 selectorIndex;\\n // loop through function selectors\\n for (uint256 slotIndex; selectorIndex < ds.selectorCount; slotIndex++) {\\n bytes32 slot = ds.selectorSlots[slotIndex];\\n for (\\n uint256 selectorSlotIndex;\\n selectorSlotIndex < 8;\\n selectorSlotIndex++\\n ) {\\n selectorIndex++;\\n if (selectorIndex > ds.selectorCount) {\\n break;\\n }\\n bytes4 selector = bytes4(slot << (selectorSlotIndex << 5));\\n address facetAddress_ = address(bytes20(ds.facets[selector]));\\n bool continueLoop;\\n for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) {\\n if (facetAddress_ == facetAddresses_[facetIndex]) {\\n continueLoop = true;\\n break;\\n }\\n }\\n if (continueLoop) {\\n continue;\\n }\\n facetAddresses_[numFacets] = facetAddress_;\\n numFacets++;\\n }\\n }\\n // Set the number of facet addresses in the array\\n assembly {\\n mstore(facetAddresses_, numFacets)\\n }\\n }\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(\\n bytes4 _functionSelector\\n ) external view override returns (address facetAddress_) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n facetAddress_ = address(bytes20(ds.facets[_functionSelector]));\\n }\\n\\n // This implements ERC-165.\\n function supportsInterface(\\n bytes4 _interfaceId\\n ) external view override returns (bool) {\\n LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();\\n return ds.supportedInterfaces[_interfaceId];\\n }\\n}\\n\",\"keccak256\":\"0x1b525af17a3f7f703dd7ac2606b6b266e1b2bfa90901c34991cb0fecdd0b28b5\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n enum FacetCutAction {\\n Add,\\n Replace,\\n Remove\\n }\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external;\\n\\n event DiamondCut(FacetCut[] diamondCut, address init, bytes callData);\\n}\\n\",\"keccak256\":\"0x6a3129be1f39b6fec871f2c94bf7debf2d6a4e665547a4d83e7f2def38359e44\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondLoupe.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\n// A loupe is a small magnifying glass used to look at diamonds.\\n// These functions look at diamonds\\ninterface IDiamondLoupe {\\n /// These functions are expected to be called frequently\\n /// by tools.\\n\\n struct Facet {\\n address facetAddress;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Gets all facet addresses and their four byte function selectors.\\n /// @return facets_ Facet\\n function facets() external view returns (Facet[] memory facets_);\\n\\n /// @notice Gets all the function selectors supported by a specific facet.\\n /// @param _facet The facet address.\\n /// @return facetFunctionSelectors_\\n function facetFunctionSelectors(\\n address _facet\\n ) external view returns (bytes4[] memory facetFunctionSelectors_);\\n\\n /// @notice Get all the facet addresses used by a diamond.\\n /// @return facetAddresses_\\n function facetAddresses()\\n external\\n view\\n returns (address[] memory facetAddresses_);\\n\\n /// @notice Gets the facet that supports the given selector.\\n /// @dev If facet is not found return address(0).\\n /// @param _functionSelector The function selector.\\n /// @return facetAddress_ The facet address.\\n function facetAddress(\\n bytes4 _functionSelector\\n ) external view returns (address facetAddress_);\\n}\\n\",\"keccak256\":\"0xdc5991b0218ab6b2cd78983c19f74a789a79ec9a9ba756ae05c8dcd512c13e38\",\"license\":\"MIT\"},\"contracts/libraries/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // maps function selectors to the facets that execute the functions.\\n // and maps the selectors to their position in the selectorSlots array.\\n // func selector => address facet, selector position\\n mapping(bytes4 => bytes32) facets;\\n // array of slots of function selectors.\\n // each slot holds 8 function selectors.\\n mapping(uint256 => bytes32) selectorSlots;\\n // The number of function selectors in selectorSlots\\n uint16 selectorCount;\\n // Used to query if a contract implements an interface.\\n // Used to implement ERC-165.\\n mapping(bytes4 => bool) supportedInterfaces;\\n // owner of the contract\\n address contractOwner;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n require(\\n msg.sender == diamondStorage().contractOwner,\\n \\\"LibDiamond: Must be contract owner\\\"\\n );\\n }\\n\\n event DiamondCut(\\n IDiamondCut.FacetCut[] diamondCut,\\n address init,\\n bytes callData\\n );\\n\\n bytes32 constant CLEAR_ADDRESS_MASK =\\n bytes32(uint256(0xffffffffffffffffffffffff));\\n bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));\\n\\n // Internal function version of diamondCut\\n // This code is almost the same as the external diamondCut,\\n // except it is using 'Facet[] memory _diamondCut' instead of\\n // 'Facet[] calldata _diamondCut'.\\n // The code is duplicated to prevent copying calldata to memory which\\n // causes an error for a two dimensional array.\\n function diamondCut(\\n IDiamondCut.FacetCut[] memory _diamondCut,\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addReplaceRemoveFacetSelectors(\\n uint256 _selectorCount,\\n bytes32 _selectorSlot,\\n address _newFacetAddress,\\n IDiamondCut.FacetCutAction _action,\\n bytes4[] memory _selectors\\n ) internal returns (uint256, bytes32) {\\n DiamondStorage storage ds = diamondStorage();\\n require(\\n _selectors.length > 0,\\n \\\"LibDiamondCut: No selectors in facet to cut\\\"\\n );\\n if (_action == IDiamondCut.FacetCutAction.Add) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Add facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) == address(0),\\n \\\"LibDiamondCut: Can't add function that already exists\\\"\\n );\\n // add facet for selector\\n ds.facets[selector] =\\n bytes20(_newFacetAddress) |\\n bytes32(_selectorCount);\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;\\n // clear selector position in slot and add selector\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |\\n (bytes32(selector) >> selectorInSlotPosition);\\n // if slot is full then write it to storage\\n if (selectorInSlotPosition == 224) {\\n // \\\"_selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"_selectorSlot / 8\\\"\\n ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;\\n _selectorSlot = 0;\\n }\\n _selectorCount++;\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Replace) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Replace facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n address oldFacetAddress = address(bytes20(oldFacet));\\n // only useful if immutable functions exist\\n require(\\n oldFacetAddress != address(this),\\n \\\"LibDiamondCut: Can't replace immutable function\\\"\\n );\\n require(\\n oldFacetAddress != _newFacetAddress,\\n \\\"LibDiamondCut: Can't replace function with same function\\\"\\n );\\n require(\\n oldFacetAddress != address(0),\\n \\\"LibDiamondCut: Can't replace function that doesn't exist\\\"\\n );\\n // replace old facet address\\n ds.facets[selector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(_newFacetAddress);\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Remove) {\\n require(\\n _newFacetAddress == address(0),\\n \\\"LibDiamondCut: Remove facet address must be address(0)\\\"\\n );\\n // \\\"_selectorCount >> 3\\\" is a gas efficient division by 8 \\\"_selectorCount / 8\\\"\\n uint256 selectorSlotCount = _selectorCount >> 3;\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotIndex = _selectorCount & 7;\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n if (_selectorSlot == 0) {\\n // get last selectorSlot\\n selectorSlotCount--;\\n _selectorSlot = ds.selectorSlots[selectorSlotCount];\\n selectorInSlotIndex = 7;\\n } else {\\n selectorInSlotIndex--;\\n }\\n bytes4 lastSelector;\\n uint256 oldSelectorsSlotCount;\\n uint256 oldSelectorInSlotPosition;\\n // adding a block here prevents stack too deep error\\n {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) != address(0),\\n \\\"LibDiamondCut: Can't remove function that doesn't exist\\\"\\n );\\n // only useful if immutable functions exist\\n require(\\n address(bytes20(oldFacet)) != address(this),\\n \\\"LibDiamondCut: Can't remove immutable function\\\"\\n );\\n // replace selector with last selector in ds.facets\\n // gets the last selector\\n lastSelector = bytes4(\\n _selectorSlot << (selectorInSlotIndex << 5)\\n );\\n if (lastSelector != selector) {\\n // update last selector slot position info\\n ds.facets[lastSelector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(ds.facets[lastSelector]);\\n }\\n delete ds.facets[selector];\\n uint256 oldSelectorCount = uint16(uint256(oldFacet));\\n // \\\"oldSelectorCount >> 3\\\" is a gas efficient division by 8 \\\"oldSelectorCount / 8\\\"\\n oldSelectorsSlotCount = oldSelectorCount >> 3;\\n // \\\"oldSelectorCount & 7\\\" is a gas efficient modulo by eight \\\"oldSelectorCount % 8\\\"\\n oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;\\n }\\n if (oldSelectorsSlotCount != selectorSlotCount) {\\n bytes32 oldSelectorSlot = ds.selectorSlots[\\n oldSelectorsSlotCount\\n ];\\n // clears the selector we are deleting and puts the last selector in its place.\\n oldSelectorSlot =\\n (oldSelectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n // update storage with the modified slot\\n ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;\\n } else {\\n // clears the selector we are deleting and puts the last selector in its place.\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n }\\n if (selectorInSlotIndex == 0) {\\n delete ds.selectorSlots[selectorSlotCount];\\n _selectorSlot = 0;\\n }\\n }\\n _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;\\n } else {\\n revert(\\\"LibDiamondCut: Incorrect FacetCutAction\\\");\\n }\\n return (_selectorCount, _selectorSlot);\\n }\\n\\n function initializeDiamondCut(\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n if (_init == address(0)) {\\n require(\\n _calldata.length == 0,\\n \\\"LibDiamondCut: _init is address(0) but_calldata is not empty\\\"\\n );\\n } else {\\n require(\\n _calldata.length > 0,\\n \\\"LibDiamondCut: _calldata is empty but _init is not address(0)\\\"\\n );\\n if (_init != address(this)) {\\n enforceHasContractCode(\\n _init,\\n \\\"LibDiamondCut: _init address has no code\\\"\\n );\\n }\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up the error\\n revert(string(error));\\n } else {\\n revert(\\\"LibDiamondCut: _init function reverted\\\");\\n }\\n }\\n }\\n }\\n\\n function enforceHasContractCode(\\n address _contract,\\n string memory _errorMessage\\n ) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n require(contractSize > 0, _errorMessage);\\n }\\n}\\n\",\"keccak256\":\"0x581eb846bee3d62731f4fc5bf21aa9cf744f491075941de685797f107e5d06f2\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610b24806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806301ffc9a71461005c57806352ef6b2c146100bd5780637a0ed627146100d2578063adfca15e146100e7578063cdffacc614610107575b600080fd5b6100a861006a3660046108d8565b6001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100c5610159565b6040516100b49190610909565b6100da61031d565b6040516100b4919061099b565b6100fa6100f5366004610a18565b610766565b6040516100b49190610a41565b6101416101153660046108d8565b6001600160e01b0319166000908152600080516020610acf833981519152602052604090205460601c90565b6040516001600160a01b0390911681526020016100b4565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529061ffff1667ffffffffffffffff8111156101aa576101aa610a54565b6040519080825280602002602001820160405280156101d3578160200160208202803683370190505b50915060008060005b600284015461ffff16821015610315576000818152600185016020526040812054905b6008811015610300578361021281610a80565b600288015490955061ffff168511905061030057600581901b82901b6001600160e01b0319811660009081526020889052604081205460601c90805b888110156102a3578a818151811061026857610268610a99565b60200260200101516001600160a01b0316836001600160a01b03160361029157600191506102a3565b8061029b81610a80565b91505061024e565b5080156102b2575050506102ee565b818a89815181106102c5576102c5610a99565b6001600160a01b0390921660209283029190910190910152876102e781610a80565b9850505050505b806102f881610a80565b9150506101ff565b5050808061030d90610a80565b9150506101dc565b505082525090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529061ffff1667ffffffffffffffff81111561036e5761036e610a54565b6040519080825280602002602001820160405280156103b457816020015b60408051808201909152600081526060602082015281526020019060019003908161038c5790505b50600282015490925060009061ffff1667ffffffffffffffff8111156103dc576103dc610a54565b604051908082528060200260200182016040528015610405578160200160208202803683370190505b50905060008060005b600285015461ffff168210156106f4576000818152600186016020526040812054905b60088110156106df578361044481610a80565b600289015490955061ffff16851190506106df57600581901b82901b6001600160e01b0319811660009081526020899052604081205460601c90805b8881101561059d57826001600160a01b03168c82815181106104a4576104a4610a99565b6020026020010151600001516001600160a01b03160361058b57838c82815181106104d1576104d1610a99565b6020026020010151602001518b83815181106104ef576104ef610a99565b602002602001015160ff168151811061050a5761050a610a99565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060ff8a828151811061054057610540610a99565b602002602001015160ff161061055557600080fd5b89818151811061056757610567610a99565b60200260200101805180919061057c90610aaf565b60ff169052506001915061059d565b8061059581610a80565b915050610480565b5080156105ac575050506106cd565b818b89815181106105bf576105bf610a99565b60209081029190910101516001600160a01b03909116905260028a015461ffff1667ffffffffffffffff8111156105f8576105f8610a54565b604051908082528060200260200182016040528015610621578160200160208202803683370190505b508b898151811061063457610634610a99565b602002602001015160200181905250828b898151811061065657610656610a99565b60200260200101516020015160008151811061067457610674610a99565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060018989815181106106aa576106aa610a99565b60ff90921660209283029190910190910152876106c681610a80565b9850505050505b806106d781610a80565b915050610431565b505080806106ec90610a80565b91505061040e565b5060005b8281101561075b57600084828151811061071457610714610a99565b602002602001015160ff169050600087838151811061073557610735610a99565b60200260200101516020015190508181525050808061075390610a80565b9150506106f8565b508185525050505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529060009061ffff1667ffffffffffffffff8111156107ba576107ba610a54565b6040519080825280602002602001820160405280156107e3578160200160208202803683370190505b5092506000805b600284015461ffff168210156108ce576000818152600185016020526040812054905b60088110156108b9578361082081610a80565b600288015490955061ffff16851190506108b957600581901b82901b6001600160e01b0319811660009081526020889052604090205460601c6001600160a01b038a168190036108a4578189888151811061087d5761087d610a99565b6001600160e01b031990921660209283029190910190910152866108a081610a80565b9750505b505080806108b190610a80565b91505061080d565b505080806108c690610a80565b9150506107ea565b5050825250919050565b6000602082840312156108ea57600080fd5b81356001600160e01b03198116811461090257600080fd5b9392505050565b6020808252825182820181905260009190848201906040850190845b8181101561094a5783516001600160a01b031683529284019291840191600101610925565b50909695505050505050565b600081518084526020808501945080840160005b838110156109905781516001600160e01b0319168752958201959082019060010161096a565b509495945050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610a0a57888303603f19018552815180516001600160a01b031684528701518784018790526109f787850182610956565b95880195935050908601906001016109c2565b509098975050505050505050565b600060208284031215610a2a57600080fd5b81356001600160a01b038116811461090257600080fd5b6020815260006109026020830184610956565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610a9257610a92610a6a565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff8103610ac557610ac5610a6a565b6001019291505056fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131ca26469706673582212204e806037195fb66d5709c3be05fd9bd079f742dcc7fb62d9b6976c66d764ebf964736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c806301ffc9a71461005c57806352ef6b2c146100bd5780637a0ed627146100d2578063adfca15e146100e7578063cdffacc614610107575b600080fd5b6100a861006a3660046108d8565b6001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100c5610159565b6040516100b49190610909565b6100da61031d565b6040516100b4919061099b565b6100fa6100f5366004610a18565b610766565b6040516100b49190610a41565b6101416101153660046108d8565b6001600160e01b0319166000908152600080516020610acf833981519152602052604090205460601c90565b6040516001600160a01b0390911681526020016100b4565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529061ffff1667ffffffffffffffff8111156101aa576101aa610a54565b6040519080825280602002602001820160405280156101d3578160200160208202803683370190505b50915060008060005b600284015461ffff16821015610315576000818152600185016020526040812054905b6008811015610300578361021281610a80565b600288015490955061ffff168511905061030057600581901b82901b6001600160e01b0319811660009081526020889052604081205460601c90805b888110156102a3578a818151811061026857610268610a99565b60200260200101516001600160a01b0316836001600160a01b03160361029157600191506102a3565b8061029b81610a80565b91505061024e565b5080156102b2575050506102ee565b818a89815181106102c5576102c5610a99565b6001600160a01b0390921660209283029190910190910152876102e781610a80565b9850505050505b806102f881610a80565b9150506101ff565b5050808061030d90610a80565b9150506101dc565b505082525090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529061ffff1667ffffffffffffffff81111561036e5761036e610a54565b6040519080825280602002602001820160405280156103b457816020015b60408051808201909152600081526060602082015281526020019060019003908161038c5790505b50600282015490925060009061ffff1667ffffffffffffffff8111156103dc576103dc610a54565b604051908082528060200260200182016040528015610405578160200160208202803683370190505b50905060008060005b600285015461ffff168210156106f4576000818152600186016020526040812054905b60088110156106df578361044481610a80565b600289015490955061ffff16851190506106df57600581901b82901b6001600160e01b0319811660009081526020899052604081205460601c90805b8881101561059d57826001600160a01b03168c82815181106104a4576104a4610a99565b6020026020010151600001516001600160a01b03160361058b57838c82815181106104d1576104d1610a99565b6020026020010151602001518b83815181106104ef576104ef610a99565b602002602001015160ff168151811061050a5761050a610a99565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060ff8a828151811061054057610540610a99565b602002602001015160ff161061055557600080fd5b89818151811061056757610567610a99565b60200260200101805180919061057c90610aaf565b60ff169052506001915061059d565b8061059581610a80565b915050610480565b5080156105ac575050506106cd565b818b89815181106105bf576105bf610a99565b60209081029190910101516001600160a01b03909116905260028a015461ffff1667ffffffffffffffff8111156105f8576105f8610a54565b604051908082528060200260200182016040528015610621578160200160208202803683370190505b508b898151811061063457610634610a99565b602002602001015160200181905250828b898151811061065657610656610a99565b60200260200101516020015160008151811061067457610674610a99565b60200260200101906001600160e01b03191690816001600160e01b0319168152505060018989815181106106aa576106aa610a99565b60ff90921660209283029190910190910152876106c681610a80565b9850505050505b806106d781610a80565b915050610431565b505080806106ec90610a80565b91505061040e565b5060005b8281101561075b57600084828151811061071457610714610a99565b602002602001015160ff169050600087838151811061073557610735610a99565b60200260200101516020015190508181525050808061075390610a80565b9150506106f8565b508185525050505090565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54606090600080516020610acf8339815191529060009061ffff1667ffffffffffffffff8111156107ba576107ba610a54565b6040519080825280602002602001820160405280156107e3578160200160208202803683370190505b5092506000805b600284015461ffff168210156108ce576000818152600185016020526040812054905b60088110156108b9578361082081610a80565b600288015490955061ffff16851190506108b957600581901b82901b6001600160e01b0319811660009081526020889052604090205460601c6001600160a01b038a168190036108a4578189888151811061087d5761087d610a99565b6001600160e01b031990921660209283029190910190910152866108a081610a80565b9750505b505080806108b190610a80565b91505061080d565b505080806108c690610a80565b9150506107ea565b5050825250919050565b6000602082840312156108ea57600080fd5b81356001600160e01b03198116811461090257600080fd5b9392505050565b6020808252825182820181905260009190848201906040850190845b8181101561094a5783516001600160a01b031683529284019291840191600101610925565b50909695505050505050565b600081518084526020808501945080840160005b838110156109905781516001600160e01b0319168752958201959082019060010161096a565b509495945050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610a0a57888303603f19018552815180516001600160a01b031684528701518784018790526109f787850182610956565b95880195935050908601906001016109c2565b509098975050505050505050565b600060208284031215610a2a57600080fd5b81356001600160a01b038116811461090257600080fd5b6020815260006109026020830184610956565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201610a9257610a92610a6a565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff8103610ac557610ac5610a6a565b6001019291505056fec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131ca26469706673582212204e806037195fb66d5709c3be05fd9bd079f742dcc7fb62d9b6976c66d764ebf964736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "facetAddress(bytes4)": { + "details": "If facet is not found return address(0).", + "params": { + "_functionSelector": "The function selector." + }, + "returns": { + "facetAddress_": "The facet address." + } + }, + "facetAddresses()": { + "returns": { + "facetAddresses_": "facetAddresses_" + } + }, + "facetFunctionSelectors(address)": { + "params": { + "_facet": "The facet address." + }, + "returns": { + "facetFunctionSelectors_": "The selectors associated with a facet address." + } + }, + "facets()": { + "returns": { + "facets_": "Facet" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "facetAddress(bytes4)": { + "notice": "Gets the facet that supports the given selector." + }, + "facetAddresses()": { + "notice": "Get all the facet addresses used by a diamond." + }, + "facetFunctionSelectors(address)": { + "notice": "Gets all the function selectors supported by a specific facet." + }, + "facets()": { + "notice": "Gets all facets and their selectors." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/ERC20PortalFacet.json b/onchain/rollups/deployments/gnosis_chiado/ERC20PortalFacet.json new file mode 100644 index 00000000..e7835cd1 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/ERC20PortalFacet.json @@ -0,0 +1,121 @@ +{ + "address": "0x0328426f3cf581F1Cf5Ba3492a3d1C5AB551de62", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC20", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ERC20Deposited", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_ERC20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "erc20Deposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x5803dfcd2bbf5d6c9f7a4fed23f10f6565b08b4164fe1600c61fbd922adef01b", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 1, + "gasUsed": "480902", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x497b9f22357805a74ff4499883a8811861783f35a7b5aa2ff440d4181cbecb93", + "transactionHash": "0x5803dfcd2bbf5d6c9f7a4fed23f10f6565b08b4164fe1600c61fbd922adef01b", + "logs": [], + "blockNumber": 1143560, + "cumulativeGasUsed": "1909327", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ERC20\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"ERC20Deposited\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ERC20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"erc20Deposit\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"erc20Deposit(address,uint256,bytes)\":{\"params\":{\"_ERC20\":\"address of the ERC20 token contract\",\"_amount\":\"amount of the ERC20 token to be deposited\",\"_data\":\"information to be interpreted by L2\"},\"returns\":{\"_0\":\"hash of input generated by deposit\"}}},\"version\":1},\"userdoc\":{\"events\":{\"ERC20Deposited(address,address,uint256,bytes)\":{\"notice\":\"emitted on ERC20 deposited\"}},\"kind\":\"user\",\"methods\":{\"erc20Deposit(address,uint256,bytes)\":{\"notice\":\"deposit an amount of a generic ERC20 in the portal and create tokens in L2\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/ERC20PortalFacet.sol\":\"ERC20PortalFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/ERC20PortalFacet.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Generic ERC20 Portal facet\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\nimport {IERC20Portal} from \\\"../interfaces/IERC20Portal.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\n\\ncontract ERC20PortalFacet is IERC20Portal {\\n using LibInput for LibInput.DiamondStorage;\\n\\n bytes32 constant INPUT_HEADER = keccak256(\\\"ERC20_Transfer\\\");\\n\\n /// @notice deposit an amount of a generic ERC20 in the portal and create tokens in L2\\n /// @param _ERC20 address of the ERC20 token contract\\n /// @param _amount amount of the ERC20 token to be deposited\\n /// @param _data information to be interpreted by L2\\n /// @return hash of input generated by deposit\\n function erc20Deposit(\\n address _ERC20,\\n uint256 _amount,\\n bytes calldata _data\\n ) public override returns (bytes32) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n IERC20 token = IERC20(_ERC20);\\n\\n require(\\n token.transferFrom(msg.sender, address(this), _amount),\\n \\\"ERC20 transferFrom failed\\\"\\n );\\n\\n bytes memory input = abi.encode(\\n INPUT_HEADER,\\n msg.sender,\\n _ERC20,\\n _amount,\\n _data\\n );\\n\\n emit ERC20Deposited(_ERC20, msg.sender, _amount, _data);\\n return inputDS.addInternalInput(input);\\n }\\n}\\n\",\"keccak256\":\"0x30d5d1aad8854d02b7783c1b07812bc8a637d64c2dcf43638aeb7c62de47ed3a\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IERC20Portal.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Generic ERC20 Portal interface\\npragma solidity >=0.7.0;\\n\\ninterface IERC20Portal {\\n /// @notice deposit an amount of a generic ERC20 token in the portal and create tokens in L2\\n /// @param _ERC20 address of the ERC20 token contract\\n /// @param _amount amount of the ERC20 token to be deposited\\n /// @param _data information to be interpreted by L2\\n /// @return hash of input generated by deposit\\n function erc20Deposit(\\n address _ERC20,\\n uint256 _amount,\\n bytes calldata _data\\n ) external returns (bytes32);\\n\\n /// @notice emitted on ERC20 deposited\\n event ERC20Deposited(\\n address ERC20,\\n address sender,\\n uint256 amount,\\n bytes data\\n );\\n}\\n\",\"keccak256\":\"0xc252480d20774dc9d6bdb0f632e364f4232d3be447db5a45f86ae1c904adacc6\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506107b9806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cb1061a614610030575b600080fd5b61004361003e36600461053b565b610055565b60405190815260200160405180910390f35b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6040516323b872dd60e01b81523360048201523060248201526044810187905290915086906001600160a01b038216906323b872dd906064016020604051808303816000875af11580156100d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f591906105d0565b6101465760405162461bcd60e51b815260206004820152601960248201527f4552433230207472616e7366657246726f6d206661696c65640000000000000060448201526064015b60405180910390fd5b60007f59da2a984e165ae4487c99e5d1dca7e04c8a99301be6bc092932cb5d7f03437833898989896040516020016101839695949392919061061b565b60405160208183030381529060405290507f29e6a9ed1b00933e0de5679ea9bc6ad323969a70b69b627425b46ac0431c7b0188338989896040516101cb959493929190610655565b60405180910390a16101dd83826101e9565b98975050505050505050565b60006101f68383306101fd565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c9111156102775760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d0000000000000000604482015260640161013d565b610280816103a2565b1561028e5761028e8561047a565b600085600301546000146102a557856001016102a7565b855b905060006102b483610499565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161035991906106aa565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d60405161038d939291906106c1565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156103ca576103ca61072d565b600184015490915063ffffffff6801000000000000000082048116911660008360028111156103fb576103fb61072d565b148015610410575061040d8183610743565b42115b1561046f576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f9161045c9161075b565b60405180910390a1506001949350505050565b506000949350505050565b60038101541561048b57600061048e565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156105055761050561072d565b9050600081600281111561051b5761051b61072d565b146105305761052b826001610743565b610532565b815b95945050505050565b6000806000806060858703121561055157600080fd5b84356001600160a01b038116811461056857600080fd5b935060208501359250604085013567ffffffffffffffff8082111561058c57600080fd5b818701915087601f8301126105a057600080fd5b8135818111156105af57600080fd5b8860208285010111156105c157600080fd5b95989497505060200194505050565b6000602082840312156105e257600080fd5b815180151581146101f657600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8681526001600160a01b038681166020830152851660408201526060810184905260a0608082018190526000906101dd90830184866105f2565b6001600160a01b038681168252851660208201526040810184905260806060820181905260009061068990830184866105f2565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156106bc576106bc610694565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b81811015610703578581018301518582016080015282016106e7565b81811115610715576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b6000821982111561075657610756610694565b500190565b602081016003831061077d57634e487b7160e01b600052602160045260246000fd5b9190529056fea26469706673582212205a6d7e95e471f4059b0981b363bccb6296e05bfe58ac6244f725c2fd38ee94ab64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cb1061a614610030575b600080fd5b61004361003e36600461053b565b610055565b60405190815260200160405180910390f35b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6040516323b872dd60e01b81523360048201523060248201526044810187905290915086906001600160a01b038216906323b872dd906064016020604051808303816000875af11580156100d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100f591906105d0565b6101465760405162461bcd60e51b815260206004820152601960248201527f4552433230207472616e7366657246726f6d206661696c65640000000000000060448201526064015b60405180910390fd5b60007f59da2a984e165ae4487c99e5d1dca7e04c8a99301be6bc092932cb5d7f03437833898989896040516020016101839695949392919061061b565b60405160208183030381529060405290507f29e6a9ed1b00933e0de5679ea9bc6ad323969a70b69b627425b46ac0431c7b0188338989896040516101cb959493929190610655565b60405180910390a16101dd83826101e9565b98975050505050505050565b60006101f68383306101fd565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c9111156102775760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d0000000000000000604482015260640161013d565b610280816103a2565b1561028e5761028e8561047a565b600085600301546000146102a557856001016102a7565b855b905060006102b483610499565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161035991906106aa565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d60405161038d939291906106c1565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156103ca576103ca61072d565b600184015490915063ffffffff6801000000000000000082048116911660008360028111156103fb576103fb61072d565b148015610410575061040d8183610743565b42115b1561046f576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f9161045c9161075b565b60405180910390a1506001949350505050565b506000949350505050565b60038101541561048b57600061048e565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156105055761050561072d565b9050600081600281111561051b5761051b61072d565b146105305761052b826001610743565b610532565b815b95945050505050565b6000806000806060858703121561055157600080fd5b84356001600160a01b038116811461056857600080fd5b935060208501359250604085013567ffffffffffffffff8082111561058c57600080fd5b818701915087601f8301126105a057600080fd5b8135818111156105af57600080fd5b8860208285010111156105c157600080fd5b95989497505060200194505050565b6000602082840312156105e257600080fd5b815180151581146101f657600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8681526001600160a01b038681166020830152851660408201526060810184905260a0608082018190526000906101dd90830184866105f2565b6001600160a01b038681168252851660208201526040810184905260806060820181905260009061068990830184866105f2565b979650505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156106bc576106bc610694565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b81811015610703578581018301518582016080015282016106e7565b81811115610715576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b6000821982111561075657610756610694565b500190565b602081016003831061077d57634e487b7160e01b600052602160045260246000fd5b9190529056fea26469706673582212205a6d7e95e471f4059b0981b363bccb6296e05bfe58ac6244f725c2fd38ee94ab64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "erc20Deposit(address,uint256,bytes)": { + "params": { + "_ERC20": "address of the ERC20 token contract", + "_amount": "amount of the ERC20 token to be deposited", + "_data": "information to be interpreted by L2" + }, + "returns": { + "_0": "hash of input generated by deposit" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "ERC20Deposited(address,address,uint256,bytes)": { + "notice": "emitted on ERC20 deposited" + } + }, + "kind": "user", + "methods": { + "erc20Deposit(address,uint256,bytes)": { + "notice": "deposit an amount of a generic ERC20 in the portal and create tokens in L2" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/ERC721PortalFacet.json b/onchain/rollups/deployments/gnosis_chiado/ERC721PortalFacet.json new file mode 100644 index 00000000..e52e3922 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/ERC721PortalFacet.json @@ -0,0 +1,190 @@ +{ + "address": "0xCF8E4cb394805b96290FEcE429E98613aB80b1c3", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC721", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ERC721Received", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC721", + "type": "address" + }, + { + "indexed": false, + "internalType": "address payable", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ERC721Withdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "erc721Withdrawal", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x1df4fc1cc61f6b5657659757219069fde794940463ed86b8e58fced849738b21", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "556226", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf7524d9b60f9da7dbd347a1d48cfae02e841e57a2720adcab6beeeedfaac6ee3", + "transactionHash": "0x1df4fc1cc61f6b5657659757219069fde794940463ed86b8e58fced849738b21", + "logs": [], + "blockNumber": 1143562, + "cumulativeGasUsed": "556226", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ERC721\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"ERC721Received\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ERC721\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address payable\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ERC721Withdrawn\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"erc721Withdrawal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_operator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"erc721Withdrawal(bytes)\":{\"details\":\"can only be called by the Rollups contract\",\"params\":{\"_data\":\"data with withdrawal information\"}},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"The ERC721 smart contract calls this function on the recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return of other than the magic value MUST result in the transaction being reverted. Note: the contract address is always the message sender.\",\"params\":{\"_data\":\"Additional data to be interpreted by L2\",\"_from\":\"The address which previously owned the token\",\"_operator\":\"The address which called `safeTransferFrom` function\",\"_tokenId\":\"The NFT identifier which is being transferred\"},\"returns\":{\"_0\":\"this function selector unless throwing\"}}},\"version\":1},\"userdoc\":{\"events\":{\"ERC721Received(address,address,address,uint256,bytes)\":{\"notice\":\"emitted on a call to `onERC721Received`\"},\"ERC721Withdrawn(address,address,uint256)\":{\"notice\":\"emitted on ERC721 withdrawal\"}},\"kind\":\"user\",\"methods\":{\"erc721Withdrawal(bytes)\":{\"notice\":\"withdraw an ERC721 token from the portal\"},\"onERC721Received(address,address,uint256,bytes)\":{\"notice\":\"Handle the receipt of an NFT\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/ERC721PortalFacet.sol\":\"ERC721PortalFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xed6a749c5373af398105ce6ee3ac4763aa450ea7285d268c85d9eeca809cdb1f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/ERC721PortalFacet.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Generic ERC721 Portal facet\\npragma solidity ^0.8.0;\\n\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\nimport {IERC721Portal} from \\\"../interfaces/IERC721Portal.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\n\\ncontract ERC721PortalFacet is IERC721Portal {\\n using LibInput for LibInput.DiamondStorage;\\n\\n bytes32 constant INPUT_HEADER = keccak256(\\\"ERC721_Transfer\\\");\\n\\n /// @notice Handle the receipt of an NFT\\n /// @dev The ERC721 smart contract calls this function on the recipient\\n /// after a `transfer`. This function MAY throw to revert and reject the\\n /// transfer. Return of other than the magic value MUST result in the\\n /// transaction being reverted.\\n /// Note: the contract address is always the message sender.\\n /// @param _operator The address which called `safeTransferFrom` function\\n /// @param _from The address which previously owned the token\\n /// @param _tokenId The NFT identifier which is being transferred\\n /// @param _data Additional data to be interpreted by L2\\n /// @return this function selector unless throwing\\n function onERC721Received(\\n address _operator,\\n address _from,\\n uint256 _tokenId,\\n bytes calldata _data\\n ) public override returns (bytes4) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n address erc721Contract = msg.sender;\\n\\n bytes memory input = abi.encode(\\n INPUT_HEADER,\\n erc721Contract,\\n _operator,\\n _from,\\n _tokenId,\\n _data\\n );\\n\\n inputDS.addInternalInput(input);\\n\\n emit ERC721Received(erc721Contract, _operator, _from, _tokenId, _data);\\n\\n // return the magic value to approve the transfer\\n return this.onERC721Received.selector;\\n }\\n\\n /// @notice withdraw an ERC721 token from the portal\\n /// @param _data data with withdrawal information\\n /// @dev can only be called by the Rollups contract\\n function erc721Withdrawal(\\n bytes calldata _data\\n ) public override returns (bool) {\\n // Delegate calls preserve msg.sender, msg.value and address(this)\\n require(msg.sender == address(this), \\\"only itself\\\");\\n\\n (address tokenAddr, address payable receiver, uint256 tokenId) = abi\\n .decode(_data, (address, address, uint256));\\n\\n IERC721 token = IERC721(tokenAddr);\\n\\n // transfer reverts on failure\\n token.safeTransferFrom(address(this), receiver, tokenId);\\n\\n emit ERC721Withdrawn(tokenAddr, receiver, tokenId);\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xbd1cd5ef628fd33a3684a191ffd12dc66144031399a33e5886aea6878c36b420\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IERC721Portal.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Generic ERC721 Portal interface\\npragma solidity >=0.7.0;\\n\\nimport {IERC721Receiver} from \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\ninterface IERC721Portal is IERC721Receiver {\\n /// @notice withdraw an ERC721 token from the portal\\n /// @param _data data with withdrawal information\\n /// @dev can only be called by the Rollups contract\\n function erc721Withdrawal(bytes calldata _data) external returns (bool);\\n\\n /// @notice emitted on a call to `onERC721Received`\\n event ERC721Received(\\n address ERC721,\\n address operator,\\n address sender,\\n uint256 tokenId,\\n bytes data\\n );\\n\\n /// @notice emitted on ERC721 withdrawal\\n event ERC721Withdrawn(\\n address ERC721,\\n address payable receiver,\\n uint256 tokenId\\n );\\n}\\n\",\"keccak256\":\"0x44d396dc8754fbbafd5b7cadf77a1acf13d9dab26ce31effc1d7f32308726ca0\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610915806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063150b7a021461003b57806315e55ce51461006c575b600080fd5b61004e61004936600461063a565b61008f565b6040516001600160e01b031990911681526020015b60405180910390f35b61007f61007a3660046106ad565b610168565b6040519015158152602001610063565b6040516000907f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff90339083906100f5907f64d9de45e7db1c0a7cb7960ad25107a6379b6ab85b30444f3a8d724857c1ac789084908c908c908c908c908c90602001610718565b60408051601f1981840301815291905290506101118382610287565b507f33dcfebf3eaf42764314a95335af55bb1c008027c47c827e6e09119071639e1d828a8a8a8a8a60405161014b96959493929190610767565b60405180910390a150630a85bd0160e11b98975050505050505050565b60003330146101ac5760405162461bcd60e51b815260206004820152600b60248201526a37b7363c9034ba39b2b63360a91b60448201526064015b60405180910390fd5b600080806101bc858701876107af565b604051632142170760e11b81523060048201526001600160a01b03808416602483015260448201839052939650919450925084918216906342842e0e90606401600060405180830381600087803b15801561021657600080fd5b505af115801561022a573d6000803e3d6000fd5b5050604080516001600160a01b038089168252871660208201529081018590527feea167c0d54572a80626f5fd092a7c1f7b5d8e309533747e7e7d77b0558d6cf19250606001905060405180910390a15060019695505050505050565b600061029483833061029b565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c9111156103155760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d000000000000000060448201526064016101a3565b61031e81610440565b1561032c5761032c85610518565b600085600301546000146103435785600101610345565b855b9050600061035283610537565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e084018290526101008085018290528551808603909101815261012090940190945282519282019290922060018086018955600089815292909220909401849055865494955090939192916103f79190610806565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d60405161042b9392919061081d565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff16600281111561046857610468610889565b600184015490915063ffffffff68010000000000000000820481169116600083600281111561049957610499610889565b1480156104ae57506104ab818361089f565b42115b1561050d576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f916104fa916108b7565b60405180910390a1506001949350505050565b506000949350505050565b60038101541561052957600061052c565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156105a3576105a3610889565b905060008160028111156105b9576105b9610889565b146105ce576105c982600161089f565b6105d0565b815b95945050505050565b6001600160a01b03811681146105ee57600080fd5b50565b60008083601f84011261060357600080fd5b50813567ffffffffffffffff81111561061b57600080fd5b60208301915083602082850101111561063357600080fd5b9250929050565b60008060008060006080868803121561065257600080fd5b853561065d816105d9565b9450602086013561066d816105d9565b935060408601359250606086013567ffffffffffffffff81111561069057600080fd5b61069c888289016105f1565b969995985093965092949392505050565b600080602083850312156106c057600080fd5b823567ffffffffffffffff8111156106d757600080fd5b6106e3858286016105f1565b90969095509350505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8781526001600160a01b0387811660208301528681166040830152851660608201526080810184905260c060a0820181905260009061075a90830184866106ef565b9998505050505050505050565b6001600160a01b0387811682528681166020830152851660408201526060810184905260a0608082018190526000906107a390830184866106ef565b98975050505050505050565b6000806000606084860312156107c457600080fd5b83356107cf816105d9565b925060208401356107df816105d9565b929592945050506040919091013590565b634e487b7160e01b600052601160045260246000fd5b600082821015610818576108186107f0565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561085f57858101830151858201608001528201610843565b81811115610871576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156108b2576108b26107f0565b500190565b60208101600383106108d957634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220ada45102ca8542269d607ca3adc88e35886a8c2ebeb4598d141e42101f76ec9664736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063150b7a021461003b57806315e55ce51461006c575b600080fd5b61004e61004936600461063a565b61008f565b6040516001600160e01b031990911681526020015b60405180910390f35b61007f61007a3660046106ad565b610168565b6040519015158152602001610063565b6040516000907f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff90339083906100f5907f64d9de45e7db1c0a7cb7960ad25107a6379b6ab85b30444f3a8d724857c1ac789084908c908c908c908c908c90602001610718565b60408051601f1981840301815291905290506101118382610287565b507f33dcfebf3eaf42764314a95335af55bb1c008027c47c827e6e09119071639e1d828a8a8a8a8a60405161014b96959493929190610767565b60405180910390a150630a85bd0160e11b98975050505050505050565b60003330146101ac5760405162461bcd60e51b815260206004820152600b60248201526a37b7363c9034ba39b2b63360a91b60448201526064015b60405180910390fd5b600080806101bc858701876107af565b604051632142170760e11b81523060048201526001600160a01b03808416602483015260448201839052939650919450925084918216906342842e0e90606401600060405180830381600087803b15801561021657600080fd5b505af115801561022a573d6000803e3d6000fd5b5050604080516001600160a01b038089168252871660208201529081018590527feea167c0d54572a80626f5fd092a7c1f7b5d8e309533747e7e7d77b0558d6cf19250606001905060405180910390a15060019695505050505050565b600061029483833061029b565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c9111156103155760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d000000000000000060448201526064016101a3565b61031e81610440565b1561032c5761032c85610518565b600085600301546000146103435785600101610345565b855b9050600061035283610537565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e084018290526101008085018290528551808603909101815261012090940190945282519282019290922060018086018955600089815292909220909401849055865494955090939192916103f79190610806565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d60405161042b9392919061081d565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff16600281111561046857610468610889565b600184015490915063ffffffff68010000000000000000820481169116600083600281111561049957610499610889565b1480156104ae57506104ab818361089f565b42115b1561050d576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f916104fa916108b7565b60405180910390a1506001949350505050565b506000949350505050565b60038101541561052957600061052c565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff1660028111156105a3576105a3610889565b905060008160028111156105b9576105b9610889565b146105ce576105c982600161089f565b6105d0565b815b95945050505050565b6001600160a01b03811681146105ee57600080fd5b50565b60008083601f84011261060357600080fd5b50813567ffffffffffffffff81111561061b57600080fd5b60208301915083602082850101111561063357600080fd5b9250929050565b60008060008060006080868803121561065257600080fd5b853561065d816105d9565b9450602086013561066d816105d9565b935060408601359250606086013567ffffffffffffffff81111561069057600080fd5b61069c888289016105f1565b969995985093965092949392505050565b600080602083850312156106c057600080fd5b823567ffffffffffffffff8111156106d757600080fd5b6106e3858286016105f1565b90969095509350505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8781526001600160a01b0387811660208301528681166040830152851660608201526080810184905260c060a0820181905260009061075a90830184866106ef565b9998505050505050505050565b6001600160a01b0387811682528681166020830152851660408201526060810184905260a0608082018190526000906107a390830184866106ef565b98975050505050505050565b6000806000606084860312156107c457600080fd5b83356107cf816105d9565b925060208401356107df816105d9565b929592945050506040919091013590565b634e487b7160e01b600052601160045260246000fd5b600082821015610818576108186107f0565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561085f57858101830151858201608001528201610843565b81811115610871576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156108b2576108b26107f0565b500190565b60208101600383106108d957634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220ada45102ca8542269d607ca3adc88e35886a8c2ebeb4598d141e42101f76ec9664736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "erc721Withdrawal(bytes)": { + "details": "can only be called by the Rollups contract", + "params": { + "_data": "data with withdrawal information" + } + }, + "onERC721Received(address,address,uint256,bytes)": { + "details": "The ERC721 smart contract calls this function on the recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return of other than the magic value MUST result in the transaction being reverted. Note: the contract address is always the message sender.", + "params": { + "_data": "Additional data to be interpreted by L2", + "_from": "The address which previously owned the token", + "_operator": "The address which called `safeTransferFrom` function", + "_tokenId": "The NFT identifier which is being transferred" + }, + "returns": { + "_0": "this function selector unless throwing" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "ERC721Received(address,address,address,uint256,bytes)": { + "notice": "emitted on a call to `onERC721Received`" + }, + "ERC721Withdrawn(address,address,uint256)": { + "notice": "emitted on ERC721 withdrawal" + } + }, + "kind": "user", + "methods": { + "erc721Withdrawal(bytes)": { + "notice": "withdraw an ERC721 token from the portal" + }, + "onERC721Received(address,address,uint256,bytes)": { + "notice": "Handle the receipt of an NFT" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/EtherPortalFacet.json b/onchain/rollups/deployments/gnosis_chiado/EtherPortalFacet.json new file mode 100644 index 00000000..5700e7e4 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/EtherPortalFacet.json @@ -0,0 +1,153 @@ +{ + "address": "0x1ab5f2688Faec8Dd89e0E2BF23506dB4A4EE5eCA", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "EtherDeposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address payable", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "EtherWithdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "etherDeposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "etherWithdrawal", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xf919d026049269b3c91e82ff02ebca16d69b66ef98126cb1ab75aa6b1dcd50e5", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "507160", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x976038a013f0c5aeabf7e268e6fdb0f59b4d3d4bef6fc0528a871496c7a4a984", + "transactionHash": "0xf919d026049269b3c91e82ff02ebca16d69b66ef98126cb1ab75aa6b1dcd50e5", + "logs": [], + "blockNumber": 1143564, + "cumulativeGasUsed": "507160", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"EtherDeposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address payable\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EtherWithdrawn\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"etherDeposit\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"etherWithdrawal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"etherDeposit(bytes)\":{\"params\":{\"_data\":\"information to be interpreted by L2\"},\"returns\":{\"_0\":\"hash of input generated by deposit\"}},\"etherWithdrawal(bytes)\":{\"details\":\"can only be called by the Rollups contract\",\"params\":{\"_data\":\"data with withdrawal information\"}}},\"version\":1},\"userdoc\":{\"events\":{\"EtherDeposited(address,uint256,bytes)\":{\"notice\":\"emitted on Ether deposited\"},\"EtherWithdrawn(address,uint256)\":{\"notice\":\"emitted on Ether withdrawal\"}},\"kind\":\"user\",\"methods\":{\"etherDeposit(bytes)\":{\"notice\":\"deposit an amount of Ether in the portal and create Ether in L2\"},\"etherWithdrawal(bytes)\":{\"notice\":\"withdraw an amount of Ether from the portal\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/EtherPortalFacet.sol\":\"EtherPortalFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/EtherPortalFacet.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Ether Portal facet\\npragma solidity ^0.8.0;\\n\\nimport {IEtherPortal} from \\\"../interfaces/IEtherPortal.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\n\\ncontract EtherPortalFacet is IEtherPortal {\\n using LibInput for LibInput.DiamondStorage;\\n\\n bytes32 constant INPUT_HEADER = keccak256(\\\"Ether_Transfer\\\");\\n\\n /// @notice deposit an amount of Ether in the portal and create Ether in L2\\n /// @param _data information to be interpreted by L2\\n /// @return hash of input generated by deposit\\n function etherDeposit(\\n bytes calldata _data\\n ) public payable override returns (bytes32) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n bytes memory input = abi.encode(\\n INPUT_HEADER,\\n msg.sender,\\n msg.value,\\n _data\\n );\\n\\n emit EtherDeposited(msg.sender, msg.value, _data);\\n return inputDS.addInternalInput(input);\\n }\\n\\n /// @notice withdraw an amount of Ether from the portal\\n /// @param _data data with withdrawal information\\n /// @dev can only be called by the Rollups contract\\n function etherWithdrawal(\\n bytes calldata _data\\n ) public override returns (bool) {\\n // Delegate calls preserve msg.sender, msg.value and address(this)\\n require(msg.sender == address(this), \\\"only itself\\\");\\n\\n (address payable receiver, uint256 value) = abi.decode(\\n _data,\\n (address, uint256)\\n );\\n\\n // We used to call receiver.transfer(value) but it's no\\n // longer considered safe, as it assumes gas costs are\\n // immutable, while in fact they are not.\\n (bool success, ) = receiver.call{value: value}(\\\"\\\");\\n require(success, \\\"transfer failed\\\");\\n\\n emit EtherWithdrawn(receiver, value);\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xb60a21f83dc7ccddcac107f89f155b9237dc35fa1ded07896be92a6935c5323a\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IEtherPortal.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Ether Portal interface\\npragma solidity >=0.7.0;\\n\\ninterface IEtherPortal {\\n /// @notice deposit an amount of Ether in the portal and create Ether in L2\\n /// @param _data information to be interpreted by L2\\n /// @return hash of input generated by deposit\\n function etherDeposit(\\n bytes calldata _data\\n ) external payable returns (bytes32);\\n\\n /// @notice withdraw an amount of Ether from the portal\\n /// @param _data data with withdrawal information\\n /// @dev can only be called by the Rollups contract\\n function etherWithdrawal(bytes calldata _data) external returns (bool);\\n\\n /// @notice emitted on Ether deposited\\n event EtherDeposited(address sender, uint256 amount, bytes data);\\n\\n /// @notice emitted on Ether withdrawal\\n event EtherWithdrawn(address payable receiver, uint256 amount);\\n}\\n\",\"keccak256\":\"0xb577c0392786e7be6dcb21608a913abe26476d6d8625075ee6e78310a5b7654e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610832806100206000396000f3fe6080604052600436106100295760003560e01c80632abfe7b31461002e57806374956b9414610054575b600080fd5b61004161003c3660046105cf565b610084565b6040519081526020015b60405180910390f35b34801561006057600080fd5b5061007461006f3660046105cf565b610146565b604051901515815260200161004b565b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff905060007ff258e0fc39d35abd7d8393dcfe7e1cf8c745ddca38ae41d451d0c55ac5f2c4ce333487876040516020016100e595949392919061066a565b60405160208183030381529060405290507fa9888e32d8ea552aaeb3018b9c85c77c66ecc61cf8d1989f9e3271a88205ee633334878760405161012b94939291906106a3565b60405180910390a161013d8282610280565b95945050505050565b600033301461018a5760405162461bcd60e51b815260206004820152600b60248201526a37b7363c9034ba39b2b63360a91b60448201526064015b60405180910390fd5b600080610199848601866106d5565b915091506000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50509050806102325760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b6044820152606401610181565b604080516001600160a01b0385168152602081018490527f06097061aeda806b5e9cb4133d9899f332ff0913956567fc0f7ea15e3d19947c910160405180910390a150600195945050505050565b600061028d838330610294565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c91111561030e5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d00000000000000006044820152606401610181565b61031781610439565b156103255761032585610511565b6000856003015460001461033c578560010161033e565b855b9050600061034b83610530565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e084018290526101008085018290528551808603909101815261012090940190945282519282019290922060018086018955600089815292909220909401849055865494955090939192916103f09190610723565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516104249392919061073a565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff166002811115610461576104616107a6565b600184015490915063ffffffff680100000000000000008204811691166000836002811115610492576104926107a6565b1480156104a757506104a481836107bc565b42115b15610506576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f916104f3916107d4565b60405180910390a1506001949350505050565b506000949350505050565b600381015415610522576000610525565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff16600281111561059c5761059c6107a6565b905060008160028111156105b2576105b26107a6565b146105c7576105c28260016107bc565b61013d565b509392505050565b600080602083850312156105e257600080fd5b823567ffffffffffffffff808211156105fa57600080fd5b818501915085601f83011261060e57600080fd5b81358181111561061d57600080fd5b86602082850101111561062f57600080fd5b60209290920196919550909350505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815260018060a01b0385166020820152836040820152608060608201526000610698608083018486610641565b979650505050505050565b60018060a01b03851681528360208201526060604082015260006106cb606083018486610641565b9695505050505050565b600080604083850312156106e857600080fd5b82356001600160a01b03811681146106ff57600080fd5b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156107355761073561070d565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561077c57858101830151858201608001528201610760565b8181111561078e576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156107cf576107cf61070d565b500190565b60208101600383106107f657634e487b7160e01b600052602160045260246000fd5b9190529056fea26469706673582212206b62acb6c77dbe7d4d69c04d66b5b6af207e0e940b9d6945a047852bcb79224a64736f6c634300080d0033", + "deployedBytecode": "0x6080604052600436106100295760003560e01c80632abfe7b31461002e57806374956b9414610054575b600080fd5b61004161003c3660046105cf565b610084565b6040519081526020015b60405180910390f35b34801561006057600080fd5b5061007461006f3660046105cf565b610146565b604051901515815260200161004b565b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff905060007ff258e0fc39d35abd7d8393dcfe7e1cf8c745ddca38ae41d451d0c55ac5f2c4ce333487876040516020016100e595949392919061066a565b60405160208183030381529060405290507fa9888e32d8ea552aaeb3018b9c85c77c66ecc61cf8d1989f9e3271a88205ee633334878760405161012b94939291906106a3565b60405180910390a161013d8282610280565b95945050505050565b600033301461018a5760405162461bcd60e51b815260206004820152600b60248201526a37b7363c9034ba39b2b63360a91b60448201526064015b60405180910390fd5b600080610199848601866106d5565b915091506000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50509050806102325760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b6044820152606401610181565b604080516001600160a01b0385168152602081018490527f06097061aeda806b5e9cb4133d9899f332ff0913956567fc0f7ea15e3d19947c910160405180910390a150600195945050505050565b600061028d838330610294565b9392505050565b600283015482516000917fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c91111561030e5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d00000000000000006044820152606401610181565b61031781610439565b156103255761032585610511565b6000856003015460001461033c578560010161033e565b855b9050600061034b83610530565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e084018290526101008085018290528551808603909101815261012090940190945282519282019290922060018086018955600089815292909220909401849055865494955090939192916103f09190610723565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516104249392919061073a565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff166002811115610461576104616107a6565b600184015490915063ffffffff680100000000000000008204811691166000836002811115610492576104926107a6565b1480156104a757506104a481836107bc565b42115b15610506576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f916104f3916107d4565b60405180910390a1506001949350505050565b506000949350505050565b600381015415610522576000610525565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff16600281111561059c5761059c6107a6565b905060008160028111156105b2576105b26107a6565b146105c7576105c28260016107bc565b61013d565b509392505050565b600080602083850312156105e257600080fd5b823567ffffffffffffffff808211156105fa57600080fd5b818501915085601f83011261060e57600080fd5b81358181111561061d57600080fd5b86602082850101111561062f57600080fd5b60209290920196919550909350505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815260018060a01b0385166020820152836040820152608060608201526000610698608083018486610641565b979650505050505050565b60018060a01b03851681528360208201526060604082015260006106cb606083018486610641565b9695505050505050565b600080604083850312156106e857600080fd5b82356001600160a01b03811681146106ff57600080fd5b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156107355761073561070d565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561077c57858101830151858201608001528201610760565b8181111561078e576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156107cf576107cf61070d565b500190565b60208101600383106107f657634e487b7160e01b600052602160045260246000fd5b9190529056fea26469706673582212206b62acb6c77dbe7d4d69c04d66b5b6af207e0e940b9d6945a047852bcb79224a64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "etherDeposit(bytes)": { + "params": { + "_data": "information to be interpreted by L2" + }, + "returns": { + "_0": "hash of input generated by deposit" + } + }, + "etherWithdrawal(bytes)": { + "details": "can only be called by the Rollups contract", + "params": { + "_data": "data with withdrawal information" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "EtherDeposited(address,uint256,bytes)": { + "notice": "emitted on Ether deposited" + }, + "EtherWithdrawn(address,uint256)": { + "notice": "emitted on Ether withdrawal" + } + }, + "kind": "user", + "methods": { + "etherDeposit(bytes)": { + "notice": "deposit an amount of Ether in the portal and create Ether in L2" + }, + "etherWithdrawal(bytes)": { + "notice": "withdraw an amount of Ether from the portal" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/FeeManagerFacet.json b/onchain/rollups/deployments/gnosis_chiado/FeeManagerFacet.json new file mode 100644 index 00000000..6fb8b924 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/FeeManagerFacet.json @@ -0,0 +1,195 @@ +{ + "address": "0x81823BDB8ae08E546AD1eCcDa910Ab32B7253343", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "FeePerClaimReset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "claims", + "type": "uint256" + } + ], + "name": "FeeRedeemed", + "type": "event" + }, + { + "inputs": [], + "name": "getFeeManagerBank", + "outputs": [ + { + "internalType": "contract IBank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "getNumClaimsRedeemed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "numClaimsRedeemable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "redeemFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "resetFeePerClaim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x8a67a1b4ca9492737265e91c7b4aedcd9ca79d8a115f13b815f2e8070df110b4", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "627903", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe853e9d9bd5d2ee197a37a634952f460aa2ef681f74384b24989edac7a2fb50b", + "transactionHash": "0x8a67a1b4ca9492737265e91c7b4aedcd9ca79d8a115f13b815f2e8070df110b4", + "logs": [], + "blockNumber": 1143566, + "cumulativeGasUsed": "627903", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"FeePerClaimReset\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"validator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"claims\",\"type\":\"uint256\"}],\"name\":\"FeeRedeemed\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getFeeManagerBank\",\"outputs\":[{\"internalType\":\"contract IBank\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"getNumClaimsRedeemed\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"numClaimsRedeemable\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_validator\",\"type\":\"address\"}],\"name\":\"redeemFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"resetFeePerClaim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getNumClaimsRedeemed(address)\":{\"params\":{\"_validator\":\"address of the validator\"}},\"numClaimsRedeemable(address)\":{\"params\":{\"_validator\":\"address of the validator\"}},\"redeemFee(address)\":{\"params\":{\"_validator\":\"address of the validator that is redeeming\"}},\"resetFeePerClaim(uint256)\":{\"params\":{\"_value\":\"the new value of fee per claim\"}}},\"version\":1},\"userdoc\":{\"events\":{\"FeePerClaimReset(uint256)\":{\"notice\":\"emitted on resetting feePerClaim\"},\"FeeRedeemed(address,uint256)\":{\"notice\":\"emitted on ERC20 funds redeemed by validator\"}},\"kind\":\"user\",\"methods\":{\"getFeeManagerBank()\":{\"notice\":\"returns the bank used to manage fees\"},\"getNumClaimsRedeemed(address)\":{\"notice\":\"this function can be called to check the number of claims that has been redeemed for the validator\"},\"numClaimsRedeemable(address)\":{\"notice\":\"this function can be called to check the number of claims that's redeemable for the validator\"},\"redeemFee(address)\":{\"notice\":\"this function can be called to redeem fees for validators\"},\"resetFeePerClaim(uint256)\":{\"notice\":\"contract owner can reset the value of fee per claim\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/FeeManagerFacet.sol\":\"FeeManagerFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/FeeManagerFacet.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager facet\\npragma solidity >=0.8.8;\\n\\nimport {IBank} from \\\"../IBank.sol\\\";\\nimport {IFeeManager} from \\\"../interfaces/IFeeManager.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\ncontract FeeManagerFacet is IFeeManager {\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n /// @notice functions modified by noReentrancy are not subject to recursion\\n modifier noReentrancy() {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n require(!feeManagerDS.lock, \\\"reentrancy not allowed\\\");\\n feeManagerDS.lock = true;\\n _;\\n feeManagerDS.lock = false;\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n address _validator\\n ) public view override returns (uint256) {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n return feeManagerDS.numClaimsRedeemable(_validator);\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n address _validator\\n ) public view override returns (uint256) {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n return feeManagerDS.getNumClaimsRedeemed(_validator);\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(uint256 _value) public override {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n feeManagerDS.onlyOwner();\\n feeManagerDS.resetFeePerClaim(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(address _validator) public override noReentrancy {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n feeManagerDS.redeemFee(_validator);\\n }\\n\\n /// @notice returns the bank used to manage fees\\n function getFeeManagerBank() public view override returns (IBank) {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n return feeManagerDS.bank;\\n }\\n}\\n\",\"keccak256\":\"0x9a0700b4e8c719870f7c20b53170ece646a2176f9a742caa1252e01a2d1cfa4f\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager interface\\npragma solidity >=0.7.0;\\n\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\ninterface IFeeManager {\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n address _validator\\n ) external view returns (uint256);\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n address _validator\\n ) external view returns (uint256);\\n\\n /// @notice contract owner can set/reset the value of fee per claim\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(uint256 _value) external;\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(address _validator) external;\\n\\n /// @notice returns the bank used to manage fees\\n function getFeeManagerBank() external view returns (IBank);\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0xed25b1867fdd7682ae01c4b833bec155596f1463abfea7728496b63e5f793753\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610a61806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80636e964cea1461005c5780637a5bf67c1461009b578063a859b983146100b0578063de7a8d11146100d1578063e8f56171146100e4575b600080fd5b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc75546040516001600160a01b0390911681526020015b60405180910390f35b6100ae6100a93660046108ea565b6100f7565b005b6100c36100be366004610903565b61011d565b604051908152602001610092565b6100ae6100df366004610903565b61013f565b6100c36100f2366004610903565b610210565b600080516020610a0c83398151915261010f8161022b565b6101198183610287565b5050565b6000600080516020610a0c8339815191526101388184610418565b9392505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7554600080516020610a0c83398151915290600160a01b900460ff16156101c65760405162461bcd60e51b81526020600482015260166024820152751c99595b9d1c985b98de481b9bdd08185b1b1bddd95960521b60448201526064015b60405180910390fd5b60028101805460ff60a01b1916600160a01b17905560006101f2600080516020610a0c83398151915290565b90506101fe81846104ac565b50600201805460ff60a01b1916905550565b6000600080516020610a0c83398151915261013881846105fc565b80546001600160a01b031633146102845760405162461bcd60e51b815260206004820152601760248201527f63616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064016101bd565b50565b6000805160206109ec83398151915260005b81600201548110156103d85760008260010182815481106102bc576102bc61092c565b6000918252602090912001546001600160a01b0316905080156103c55760006102e586836105fc565b905080156103c35760038601546102fd9084836106b6565b600387015560018601546000906103149083610958565b600288015460405163bec3fa1760e01b81526001600160a01b0386811660048301526024820184905292935091169063bec3fa1790604401600060405180830381600087803b15801561036657600080fd5b505af115801561037a573d6000803e3d6000fd5b5050604080516001600160a01b0387168152602081018690527f0544e8b0e3ef3679366e27df87030668812cb3284d1acccfb1eb8a0e7b26ead3935001905060405180910390a1505b505b50806103d081610977565b915050610299565b50600183018290556040518281527fd454bae44ce74e91cf62780bdb9278052c00cfd79c13003d5761b400475b12f69060200160405180910390a1505050565b60006001600160a01b03821661046a5760405162461bcd60e51b81526020600482015260176024820152760616464726573732073686f756c64206e6f74206265203604c1b60448201526064016101bd565b6000805160206109ec83398151915260006104858285610709565b905060006104a08287600301546107e890919063ffffffff16565b93505050505b92915050565b60006104b883836105fc565b9050600081116105025760405162461bcd60e51b81526020600482015260156024820152741b9bdd1a1a5b99c81d1bc81c995919595b481e595d605a1b60448201526064016101bd565b6000805160206109ec833981519152600061051d8285610709565b60038601549091506105309082856106b6565b600386015560018501546000906105479085610958565b600287015460405163bec3fa1760e01b81526001600160a01b0388811660048301526024820184905292935091169063bec3fa1790604401600060405180830381600087803b15801561059957600080fd5b505af11580156105ad573d6000803e3d6000fd5b5050604080516001600160a01b0389168152602081018890527f0544e8b0e3ef3679366e27df87030668812cb3284d1acccfb1eb8a0e7b26ead3935001905060405180910390a1505050505050565b60006001600160a01b03821661064e5760405162461bcd60e51b81526020600482015260176024820152760616464726573732073686f756c64206e6f74206265203604c1b60448201526064016101bd565b6000805160206109ec83398151915260006106698285610709565b905060006106848284600301546107e890919063ffffffff16565b9050600061069f8388600301546107e890919063ffffffff16565b90506106ab8183610990565b979650505050505050565b6000600883106106d85760405162461bcd60e51b81526004016101bd906109a7565b60006106e485856107e8565b905060006106f284836109d3565b90506106ff868683610836565b9695505050505050565b60006001600160a01b03821661074d5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b60448201526064016101bd565b60005b60018401548110156107a9578360010181815481106107715761077161092c565b6000918252602090912001546001600160a01b03908116908416036107975790506104a6565b806107a181610977565b915050610750565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b60448201526064016101bd565b60006008821061080a5760405162461bcd60e51b81526004016101bd906109a7565b600061081b60016340000000610990565b90508061082984601e610958565b85901c1691505092915050565b6000600883106108585760405162461bcd60e51b81526004016101bd906109a7565b61086760016340000000610990565b8211156108ac5760405162461bcd60e51b8152602060048201526013602482015272436c61696d734d61736b204f766572666c6f7760681b60448201526064016101bd565b60006108b984601e610958565b6108c860016340000000610990565b901b1990508481166108db85601e610958565b9390931b909217949350505050565b6000602082840312156108fc57600080fd5b5035919050565b60006020828403121561091557600080fd5b81356001600160a01b038116811461013857600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561097257610972610942565b500290565b60006001820161098957610989610942565b5060010190565b6000828210156109a2576109a2610942565b500390565b602080825260129082015271696e646578206f7574206f662072616e676560701b604082015260600190565b600082198211156109e6576109e6610942565b50019056fe8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fc844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc73a264697066735822122042ec7a5adee122f0bcd4ccf2225d9453a458fd404b1a13df4cbd8b36b870d84e64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c80636e964cea1461005c5780637a5bf67c1461009b578063a859b983146100b0578063de7a8d11146100d1578063e8f56171146100e4575b600080fd5b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc75546040516001600160a01b0390911681526020015b60405180910390f35b6100ae6100a93660046108ea565b6100f7565b005b6100c36100be366004610903565b61011d565b604051908152602001610092565b6100ae6100df366004610903565b61013f565b6100c36100f2366004610903565b610210565b600080516020610a0c83398151915261010f8161022b565b6101198183610287565b5050565b6000600080516020610a0c8339815191526101388184610418565b9392505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7554600080516020610a0c83398151915290600160a01b900460ff16156101c65760405162461bcd60e51b81526020600482015260166024820152751c99595b9d1c985b98de481b9bdd08185b1b1bddd95960521b60448201526064015b60405180910390fd5b60028101805460ff60a01b1916600160a01b17905560006101f2600080516020610a0c83398151915290565b90506101fe81846104ac565b50600201805460ff60a01b1916905550565b6000600080516020610a0c83398151915261013881846105fc565b80546001600160a01b031633146102845760405162461bcd60e51b815260206004820152601760248201527f63616c6c6572206973206e6f7420746865206f776e657200000000000000000060448201526064016101bd565b50565b6000805160206109ec83398151915260005b81600201548110156103d85760008260010182815481106102bc576102bc61092c565b6000918252602090912001546001600160a01b0316905080156103c55760006102e586836105fc565b905080156103c35760038601546102fd9084836106b6565b600387015560018601546000906103149083610958565b600288015460405163bec3fa1760e01b81526001600160a01b0386811660048301526024820184905292935091169063bec3fa1790604401600060405180830381600087803b15801561036657600080fd5b505af115801561037a573d6000803e3d6000fd5b5050604080516001600160a01b0387168152602081018690527f0544e8b0e3ef3679366e27df87030668812cb3284d1acccfb1eb8a0e7b26ead3935001905060405180910390a1505b505b50806103d081610977565b915050610299565b50600183018290556040518281527fd454bae44ce74e91cf62780bdb9278052c00cfd79c13003d5761b400475b12f69060200160405180910390a1505050565b60006001600160a01b03821661046a5760405162461bcd60e51b81526020600482015260176024820152760616464726573732073686f756c64206e6f74206265203604c1b60448201526064016101bd565b6000805160206109ec83398151915260006104858285610709565b905060006104a08287600301546107e890919063ffffffff16565b93505050505b92915050565b60006104b883836105fc565b9050600081116105025760405162461bcd60e51b81526020600482015260156024820152741b9bdd1a1a5b99c81d1bc81c995919595b481e595d605a1b60448201526064016101bd565b6000805160206109ec833981519152600061051d8285610709565b60038601549091506105309082856106b6565b600386015560018501546000906105479085610958565b600287015460405163bec3fa1760e01b81526001600160a01b0388811660048301526024820184905292935091169063bec3fa1790604401600060405180830381600087803b15801561059957600080fd5b505af11580156105ad573d6000803e3d6000fd5b5050604080516001600160a01b0389168152602081018890527f0544e8b0e3ef3679366e27df87030668812cb3284d1acccfb1eb8a0e7b26ead3935001905060405180910390a1505050505050565b60006001600160a01b03821661064e5760405162461bcd60e51b81526020600482015260176024820152760616464726573732073686f756c64206e6f74206265203604c1b60448201526064016101bd565b6000805160206109ec83398151915260006106698285610709565b905060006106848284600301546107e890919063ffffffff16565b9050600061069f8388600301546107e890919063ffffffff16565b90506106ab8183610990565b979650505050505050565b6000600883106106d85760405162461bcd60e51b81526004016101bd906109a7565b60006106e485856107e8565b905060006106f284836109d3565b90506106ff868683610836565b9695505050505050565b60006001600160a01b03821661074d5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b60448201526064016101bd565b60005b60018401548110156107a9578360010181815481106107715761077161092c565b6000918252602090912001546001600160a01b03908116908416036107975790506104a6565b806107a181610977565b915050610750565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b60448201526064016101bd565b60006008821061080a5760405162461bcd60e51b81526004016101bd906109a7565b600061081b60016340000000610990565b90508061082984601e610958565b85901c1691505092915050565b6000600883106108585760405162461bcd60e51b81526004016101bd906109a7565b61086760016340000000610990565b8211156108ac5760405162461bcd60e51b8152602060048201526013602482015272436c61696d734d61736b204f766572666c6f7760681b60448201526064016101bd565b60006108b984601e610958565b6108c860016340000000610990565b901b1990508481166108db85601e610958565b9390931b909217949350505050565b6000602082840312156108fc57600080fd5b5035919050565b60006020828403121561091557600080fd5b81356001600160a01b038116811461013857600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561097257610972610942565b500290565b60006001820161098957610989610942565b5060010190565b6000828210156109a2576109a2610942565b500390565b602080825260129082015271696e646578206f7574206f662072616e676560701b604082015260600190565b600082198211156109e6576109e6610942565b50019056fe8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fc844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc73a264697066735822122042ec7a5adee122f0bcd4ccf2225d9453a458fd404b1a13df4cbd8b36b870d84e64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "getNumClaimsRedeemed(address)": { + "params": { + "_validator": "address of the validator" + } + }, + "numClaimsRedeemable(address)": { + "params": { + "_validator": "address of the validator" + } + }, + "redeemFee(address)": { + "params": { + "_validator": "address of the validator that is redeeming" + } + }, + "resetFeePerClaim(uint256)": { + "params": { + "_value": "the new value of fee per claim" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "FeePerClaimReset(uint256)": { + "notice": "emitted on resetting feePerClaim" + }, + "FeeRedeemed(address,uint256)": { + "notice": "emitted on ERC20 funds redeemed by validator" + } + }, + "kind": "user", + "methods": { + "getFeeManagerBank()": { + "notice": "returns the bank used to manage fees" + }, + "getNumClaimsRedeemed(address)": { + "notice": "this function can be called to check the number of claims that has been redeemed for the validator" + }, + "numClaimsRedeemable(address)": { + "notice": "this function can be called to check the number of claims that's redeemable for the validator" + }, + "redeemFee(address)": { + "notice": "this function can be called to redeem fees for validators" + }, + "resetFeePerClaim(uint256)": { + "notice": "contract owner can reset the value of fee per claim" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/InputFacet.json b/onchain/rollups/deployments/gnosis_chiado/InputFacet.json new file mode 100644 index 00000000..3cb1673f --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/InputFacet.json @@ -0,0 +1,187 @@ +{ + "address": "0xeA8538B194742b992B19e694C13D63120908880e", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "name": "InputAdded", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "addInput", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentInbox", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + } + ], + "name": "getInput", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNumberOfInputs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xf46723e845c20fa2405d2b4e9ed8377e128a1a97b502f0981c75367d22ae5c65", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "445554", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x6b2f115d6e8e1111f75bc497395b7b344d560839ba3f94777c141444dab41580", + "transactionHash": "0xf46723e845c20fa2405d2b4e9ed8377e128a1a97b502f0981c75367d22ae5c65", + "logs": [], + "blockNumber": 1143568, + "cumulativeGasUsed": "445554", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"InputAdded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_input\",\"type\":\"bytes\"}],\"name\":\"addInput\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentInbox\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getInput\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNumberOfInputs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addInput(bytes)\":{\"details\":\"offchain code is responsible for making sure that input size is power of 2 and multiple of 8 since\",\"params\":{\"_input\":\"input to be understood by offchain machine\"}},\"getCurrentInbox()\":{\"returns\":{\"_0\":\"input inbox currently receiveing inputs\"}},\"getInput(uint256)\":{\"details\":\"currentInputBox being zero means that the inputs for the claimed epoch are on input box one\",\"params\":{\"_index\":\"index of input inside that inbox\"},\"returns\":{\"_0\":\"hash of input at index _index\"}},\"getNumberOfInputs()\":{\"details\":\"currentInputBox being zero means that the inputs for the claimed epoch are on input box one\",\"returns\":{\"_0\":\"number of inputs on that input box\"}}},\"version\":1},\"userdoc\":{\"events\":{\"InputAdded(uint256,uint256,address,uint256,bytes)\":{\"notice\":\"Indicates that an input was added to the accumulating epoch's inbox\"}},\"kind\":\"user\",\"methods\":{\"addInput(bytes)\":{\"notice\":\"add input to processed by next epoch\"},\"getCurrentInbox()\":{\"notice\":\"get inbox currently receiveing inputs\"},\"getInput(uint256)\":{\"notice\":\"get input inside inbox of currently proposed claim\"},\"getNumberOfInputs()\":{\"notice\":\"get number of inputs inside inbox of currently proposed claim\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/InputFacet.sol\":\"InputFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/InputFacet.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input facet\\npragma solidity ^0.8.0;\\n\\nimport {IInput} from \\\"../interfaces/IInput.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\n\\ncontract InputFacet is IInput {\\n using LibInput for LibInput.DiamondStorage;\\n\\n /// @notice add input to processed by next epoch\\n /// @param _input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n // the offchain machine has a 8 byte word\\n function addInput(bytes calldata _input) public override returns (bytes32) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n return inputDS.addInput(_input);\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param _index index of input inside that inbox\\n /// @return hash of input at index _index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(uint256 _index) public view override returns (bytes32) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n return inputDS.getInput(_index);\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs() public view override returns (uint256) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n return inputDS.getNumberOfInputs();\\n }\\n\\n /// @notice get inbox currently receiveing inputs\\n /// @return input inbox currently receiveing inputs\\n function getCurrentInbox() public view override returns (uint256) {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n return inputDS.currentInputBox;\\n }\\n}\\n\",\"keccak256\":\"0xe7355e94250381c1d3f4ed399ff5db753a7909296b8b9bf7437e965bcd704793\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input interface\\npragma solidity >=0.7.0;\\n\\ninterface IInput {\\n /// @notice Adds an input to the accumulating epoch's inbox\\n /// @param _input bytes array of input\\n /// @return hash of the input\\n /// @dev There is a maximum size for the input data that is defined by the DApp\\n function addInput(bytes calldata _input) external returns (bytes32);\\n\\n /// @notice Returns the hash of the input at the provided input index, for the current sealed epoch\\n /// @param _index position of the input on inbox\\n /// @return hash of the input\\n function getInput(uint256 _index) external view returns (bytes32);\\n\\n /// @notice Returns the number of inputs on the current sealed epoch's inbox\\n /// @return number of inputs of non active inbox\\n function getNumberOfInputs() external view returns (uint256);\\n\\n /// @notice Returns the internal index of the current accumulating inbox\\n /// @return index of current accumulating inbox\\n function getCurrentInbox() external view returns (uint256);\\n\\n /// @notice Indicates that an input was added to the accumulating epoch's inbox\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender address\\n /// @param timestamp block timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0x56006d5601a56b43d9274dd72c3f11915e8cfec9874dd9e96344f62bff7d4baf\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610716806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ab6dcab14610051578063a459600e14610086578063e795524414610099578063f32078e8146100a1575b600080fd5b7f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a688224991302545b60405190815260200160405180910390f35b610074610094366004610550565b6100b4565b6100746100e8565b6100746100af366004610569565b61011a565b60007f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6100e1818461018a565b9392505050565b60007f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff610114816101e4565b91505090565b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff905061018284848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525085939250506102059050565b949350505050565b600082600301546000146101bd578260000182815481106101ad576101ad6105db565b90600052602060002001546100e1565b8260010182815481106101d2576101d26105db565b90600052602060002001549392505050565b600081600301546000146101f95781546101ff565b60018201545b92915050565b60006100e18383336000807fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c905084600201548451111561028c5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d0000000000000000604482015260640160405180910390fd5b610295816103b7565b156102a3576102a38561048f565b600085600301546000146102ba57856001016102bc565b855b905060006102c9836104ae565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161036e9190610607565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516103a29392919061061e565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156103df576103df61068a565b600184015490915063ffffffff6801000000000000000082048116911660008360028111156104105761041061068a565b148015610425575061042281836106a0565b42115b15610484576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f91610471916106b8565b60405180910390a1506001949350505050565b506000949350505050565b6003810154156104a05760006104a3565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff16600281111561051a5761051a61068a565b905060008160028111156105305761053061068a565b14610545576105408260016106a0565b610547565b815b95945050505050565b60006020828403121561056257600080fd5b5035919050565b6000806020838503121561057c57600080fd5b823567ffffffffffffffff8082111561059457600080fd5b818501915085601f8301126105a857600080fd5b8135818111156105b757600080fd5b8660208285010111156105c957600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082821015610619576106196105f1565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561066057858101830151858201608001528201610644565b81811115610672576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156106b3576106b36105f1565b500190565b60208101600383106106da57634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220328b3d40c2b88f03954e8a7f51cfbded83c0547d5c86b90b0e45461f059f9f1064736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80631ab6dcab14610051578063a459600e14610086578063e795524414610099578063f32078e8146100a1575b600080fd5b7f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a688224991302545b60405190815260200160405180910390f35b610074610094366004610550565b6100b4565b6100746100e8565b6100746100af366004610569565b61011a565b60007f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff6100e1818461018a565b9392505050565b60007f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff610114816101e4565b91505090565b6000807f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff905061018284848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525085939250506102059050565b949350505050565b600082600301546000146101bd578260000182815481106101ad576101ad6105db565b90600052602060002001546100e1565b8260010182815481106101d2576101d26105db565b90600052602060002001549392505050565b600081600301546000146101f95781546101ff565b60018201545b92915050565b60006100e18383336000807fd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189c905084600201548451111561028c5760405162461bcd60e51b815260206004820152601860248201527f696e707574206c656e3a205b302c647269766553697a655d0000000000000000604482015260640160405180910390fd5b610295816103b7565b156102a3576102a38561048f565b600085600301546000146102ba57856001016102bc565b855b905060006102c9836104ae565b8254604080516001600160a01b03891660208083019190915243828401524260608301526080820185905260a08083018590528351808403909101815260c0830184528051908201208b518c83012060e0840182905261010080850182905285518086039091018152610120909401909452825192820192909220600180860189556000898152929092209094018490558654949550909391929161036e9190610607565b847fa15a0da5519c084484141aaa73e525cee96062f5decc97e070f0c4da27738bc78a428d6040516103a29392919061061e565b60405180910390a39998505050505050505050565b60018101546000908190600160801b900463ffffffff1660028111156103df576103df61068a565b600184015490915063ffffffff6801000000000000000082048116911660008360028111156104105761041061068a565b148015610425575061042281836106a0565b42115b15610484576001858101805463ffffffff60801b1916600160801b1790556040517fed606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f91610471916106b8565b60405180910390a1506001949350505050565b506000949350505050565b6003810154156104a05760006104a3565b60015b60ff16600390910155565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff16600281111561051a5761051a61068a565b905060008160028111156105305761053061068a565b14610545576105408260016106a0565b610547565b815b95945050505050565b60006020828403121561056257600080fd5b5035919050565b6000806020838503121561057c57600080fd5b823567ffffffffffffffff8082111561059457600080fd5b818501915085601f8301126105a857600080fd5b8135818111156105b757600080fd5b8660208285010111156105c957600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082821015610619576106196105f1565b500390565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561066057858101830151858201608001528201610644565b81811115610672576000608083870101525b50601f01601f19169290920160800195945050505050565b634e487b7160e01b600052602160045260246000fd5b600082198211156106b3576106b36105f1565b500190565b60208101600383106106da57634e487b7160e01b600052602160045260246000fd5b9190529056fea2646970667358221220328b3d40c2b88f03954e8a7f51cfbded83c0547d5c86b90b0e45461f059f9f1064736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "addInput(bytes)": { + "details": "offchain code is responsible for making sure that input size is power of 2 and multiple of 8 since", + "params": { + "_input": "input to be understood by offchain machine" + } + }, + "getCurrentInbox()": { + "returns": { + "_0": "input inbox currently receiveing inputs" + } + }, + "getInput(uint256)": { + "details": "currentInputBox being zero means that the inputs for the claimed epoch are on input box one", + "params": { + "_index": "index of input inside that inbox" + }, + "returns": { + "_0": "hash of input at index _index" + } + }, + "getNumberOfInputs()": { + "details": "currentInputBox being zero means that the inputs for the claimed epoch are on input box one", + "returns": { + "_0": "number of inputs on that input box" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "InputAdded(uint256,uint256,address,uint256,bytes)": { + "notice": "Indicates that an input was added to the accumulating epoch's inbox" + } + }, + "kind": "user", + "methods": { + "addInput(bytes)": { + "notice": "add input to processed by next epoch" + }, + "getCurrentInbox()": { + "notice": "get inbox currently receiveing inputs" + }, + "getInput(uint256)": { + "notice": "get input inside inbox of currently proposed claim" + }, + "getNumberOfInputs()": { + "notice": "get number of inputs inside inbox of currently proposed claim" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/OutputFacet.json b/onchain/rollups/deployments/gnosis_chiado/OutputFacet.json new file mode 100644 index 00000000..181c4088 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/OutputFacet.json @@ -0,0 +1,536 @@ +{ + "address": "0x3E1944bB826391e0F47EC96147c20B931BDA5372", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "voucherPosition", + "type": "uint256" + } + ], + "name": "VoucherExecuted", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_destination", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_payload", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "executeVoucher", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_voucher", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_input", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_epoch", + "type": "uint256" + } + ], + "name": "getBitMaskPosition", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getEpochNoticeLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getEpochVoucherLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_log2Size", + "type": "uint256" + } + ], + "name": "getIntraDrivePosition", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getNoticeMetadataLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getNumberOfFinalizedEpochs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVoucherMetadataLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_encodedNotice", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "isValidNoticeProof", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_encodedVoucher", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "isValidVoucherProof", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_notice", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "validateNotice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x5655258e1b11dd278db96af6ac043464af133a5a38fbc246db25a00b8c0bf72f", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "803716", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc080e06e97b1d0cf26d4cac62786d5cc7d4b0ab828dc9de45acb98e45a1fbbcb", + "transactionHash": "0x5655258e1b11dd278db96af6ac043464af133a5a38fbc246db25a00b8c0bf72f", + "logs": [], + "blockNumber": 1143570, + "cumulativeGasUsed": "803716", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"voucherPosition\",\"type\":\"uint256\"}],\"name\":\"VoucherExecuted\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_destination\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_payload\",\"type\":\"bytes\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"epochIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"outputIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"keccakInHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"struct OutputValidityProof\",\"name\":\"_v\",\"type\":\"tuple\"}],\"name\":\"executeVoucher\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_voucher\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_input\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"getBitMaskPosition\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEpochNoticeLog2Size\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEpochVoucherLog2Size\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_log2Size\",\"type\":\"uint256\"}],\"name\":\"getIntraDrivePosition\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNoticeMetadataLog2Size\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNumberOfFinalizedEpochs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVoucherMetadataLog2Size\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_encodedNotice\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"_epochHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"epochIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"outputIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"keccakInHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"struct OutputValidityProof\",\"name\":\"_v\",\"type\":\"tuple\"}],\"name\":\"isValidNoticeProof\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_encodedVoucher\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"_epochHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"epochIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"outputIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"keccakInHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"struct OutputValidityProof\",\"name\":\"_v\",\"type\":\"tuple\"}],\"name\":\"isValidVoucherProof\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_notice\",\"type\":\"bytes\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"epochIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"inputIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"outputIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"outputHashesRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"vouchersEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"noticesEpochRootHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"machineStateHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"keccakInHashesSiblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32[]\",\"name\":\"outputHashesInEpochSiblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"struct OutputValidityProof\",\"name\":\"_v\",\"type\":\"tuple\"}],\"name\":\"validateNotice\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"executeVoucher(address,bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"details\":\"vouchers can only be executed once\",\"params\":{\"_destination\":\"address that will execute the payload\",\"_payload\":\"payload to be executed by destination\",\"_v\":\"validity proof for this encoded voucher\"},\"returns\":{\"_0\":\"true if voucher was executed successfully\"}},\"getBitMaskPosition(uint256,uint256,uint256)\":{\"params\":{\"_epoch\":\"which epoch the voucher belongs to\",\"_input\":\"which input, inside the epoch, the voucher belongs to\",\"_voucher\":\"of voucher inside the input\"},\"returns\":{\"_0\":\"position of that voucher on bitmask\"}},\"getIntraDrivePosition(uint256,uint256)\":{\"params\":{\"_index\":\"index of intra memory range\",\"_log2Size\":\"of intra memory range\"}},\"validateNotice(bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"params\":{\"_notice\":\"notice to be verified\",\"_v\":\"validity proof for this notice\"},\"returns\":{\"_0\":\"true if notice is valid\"}}},\"version\":1},\"userdoc\":{\"events\":{\"VoucherExecuted(uint256)\":{\"notice\":\"Indicates that a voucher was executed\"}},\"kind\":\"user\",\"methods\":{\"executeVoucher(address,bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"notice\":\"executes voucher\"},\"getBitMaskPosition(uint256,uint256,uint256)\":{\"notice\":\"get voucher position on bitmask\"},\"getEpochNoticeLog2Size()\":{\"notice\":\"get log2 size of epoch notice memory range\"},\"getEpochVoucherLog2Size()\":{\"notice\":\"get log2 size of epoch voucher memory range\"},\"getNoticeMetadataLog2Size()\":{\"notice\":\"get log2 size of notice metadata memory range\"},\"getNumberOfFinalizedEpochs()\":{\"notice\":\"get number of finalized epochs\"},\"getVoucherMetadataLog2Size()\":{\"notice\":\"get log2 size of voucher metadata memory range\"},\"isValidNoticeProof(bytes,bytes32,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"notice\":\"isValidNoticeProof reverts if the proof is invalid\"},\"isValidVoucherProof(bytes,bytes32,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"notice\":\"isValidVoucherProof reverts if the proof is invalid\"},\"validateNotice(bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))\":{\"notice\":\"validates notice\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/OutputFacet.sol\":\"OutputFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@cartesi/util/contracts/Bitmask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\npragma solidity ^0.8.0;\\n\\n/// @title Bit Mask Library\\n/// @author Stephen Chen\\n/// @notice Implements bit mask with dynamic array\\nlibrary Bitmask {\\n /// @notice Set a bit in the bit mask\\n function setBit(\\n mapping(uint256 => uint256) storage bitmask,\\n uint256 _bit,\\n bool _value\\n ) public {\\n // calculate the number of bits has been store in bitmask now\\n uint256 positionOfMask = uint256(_bit / 256);\\n uint256 positionOfBit = _bit % 256;\\n\\n if (_value) {\\n bitmask[positionOfMask] =\\n bitmask[positionOfMask] |\\n (1 << positionOfBit);\\n } else {\\n bitmask[positionOfMask] =\\n bitmask[positionOfMask] &\\n ~(1 << positionOfBit);\\n }\\n }\\n\\n /// @notice Get a bit in the bit mask\\n function getBit(mapping(uint256 => uint256) storage bitmask, uint256 _bit)\\n public\\n view\\n returns (bool)\\n {\\n // calculate the number of bits has been store in bitmask now\\n uint256 positionOfMask = uint256(_bit / 256);\\n uint256 positionOfBit = _bit % 256;\\n\\n return ((bitmask[positionOfMask] & (1 << positionOfBit)) != 0);\\n }\\n}\\n\",\"keccak256\":\"0xe35cf68672f5844589c0e56f36aa3813ca4ffb882a55a46d15adac7e3cc889bd\",\"license\":\"Apache-2.0\"},\"@cartesi/util/contracts/CartesiMathV2.sol\":{\"content\":\"// Copyright 2020 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title CartesiMath\\n/// @author Felipe Argento\\npragma solidity ^0.8.0;\\n\\nlibrary CartesiMathV2 {\\n // mapping values are packed as bytes3 each\\n // see test/TestCartesiMath.ts for decimal values\\n bytes constant log2tableTimes1M =\\n hex\\\"0000000F4240182F421E8480236E082771822AD63A2DC6C0305E8532B04834C96736B3C23876D73A187A3B9D4A3D09003E5EA63FA0C540D17741F28843057D440BA745062945F60246DC1047B917488DC7495ABA4A207C4ADF8A4B98544C4B404CF8AA4DA0E64E44434EE3054F7D6D5013B750A61A5134C851BFF05247BD52CC58534DE753CC8D54486954C19C55384255AC75561E50568DE956FB575766B057D00758376F589CFA5900BA5962BC59C3135A21CA5A7EF15ADA945B34BF5B8D805BE4DF5C3AEA5C8FA95CE3265D356C5D86835DD6735E25455E73005EBFAD5F0B525F55F75F9FA25FE85A60302460770860BD0A61023061467F6189FD61CCAE620E98624FBF62902762CFD5630ECD634D12638AA963C7966403DC643F7F647A8264B4E864EEB56527EC6560906598A365D029660724663D9766738566A8F066DDDA6712476746386779AF67ACAF67DF3A6811526842FA68743268A4FC68D55C6905536934E169640A6992CF69C13169EF326A1CD46A4A186A76FF6AA38C6ACFC0\\\";\\n\\n /// @notice Approximates log2 * 1M\\n /// @param _num number to take log2 * 1M of\\n /// @return approximate log2 times 1M\\n function log2ApproxTimes1M(uint256 _num) public pure returns (uint256) {\\n require(_num > 0, \\\"Number cannot be zero\\\");\\n uint256 leading = 0;\\n\\n if (_num == 1) return 0;\\n\\n while (_num > 128) {\\n _num = _num >> 1;\\n leading += 1;\\n }\\n return (leading * uint256(1000000)) + (getLog2TableTimes1M(_num));\\n }\\n\\n /// @notice navigates log2tableTimes1M\\n /// @param _num number to take log2 of\\n /// @return result after table look-up\\n function getLog2TableTimes1M(uint256 _num) public pure returns (uint256) {\\n bytes3 result = 0;\\n for (uint8 i = 0; i < 3; i++) {\\n bytes3 tempResult = log2tableTimes1M[(_num - 1) * 3 + i];\\n result = result | (tempResult >> (i * 8));\\n }\\n\\n return uint256(uint24(result));\\n }\\n\\n /// @notice get floor of log2 of number\\n /// @param _num number to take floor(log2) of\\n /// @return floor(log2) of _num\\n function getLog2Floor(uint256 _num) public pure returns (uint8) {\\n require(_num != 0, \\\"log of zero is undefined\\\");\\n\\n return uint8(255 - clz(_num));\\n }\\n\\n /// @notice checks if a number is Power of 2\\n /// @param _num number to check\\n /// @return true if number is power of 2, false if not\\n function isPowerOf2(uint256 _num) public pure returns (bool) {\\n if (_num == 0) return false;\\n\\n return _num & (_num - 1) == 0;\\n }\\n\\n /// @notice count trailing zeros\\n /// @param _num number you want the ctz of\\n /// @dev this a binary search implementation\\n function ctz(uint256 _num) public pure returns (uint256) {\\n if (_num == 0) return 256;\\n\\n uint256 n = 0;\\n if (_num & 0x00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF == 0) {\\n n = n + 128;\\n _num = _num >> 128;\\n }\\n if (_num & 0x000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFF == 0) {\\n n = n + 64;\\n _num = _num >> 64;\\n }\\n if (_num & 0x00000000000000000000000000000000000000000000000000000000FFFFFFFF == 0) {\\n n = n + 32;\\n _num = _num >> 32;\\n }\\n if (_num & 0x000000000000000000000000000000000000000000000000000000000000FFFF == 0) {\\n n = n + 16;\\n _num = _num >> 16;\\n }\\n if (_num & 0x00000000000000000000000000000000000000000000000000000000000000FF == 0) {\\n n = n + 8;\\n _num = _num >> 8;\\n }\\n if (_num & 0x000000000000000000000000000000000000000000000000000000000000000F == 0) {\\n n = n + 4;\\n _num = _num >> 4;\\n }\\n if (_num & 0x0000000000000000000000000000000000000000000000000000000000000003 == 0) {\\n n = n + 2;\\n _num = _num >> 2;\\n }\\n if (_num & 0x0000000000000000000000000000000000000000000000000000000000000001 == 0) {\\n n = n + 1;\\n }\\n\\n return n;\\n }\\n\\n /// @notice count leading zeros\\n /// @param _num number you want the clz of\\n /// @dev this a binary search implementation\\n function clz(uint256 _num) public pure returns (uint256) {\\n if (_num == 0) return 256;\\n\\n uint256 n = 0;\\n if (_num & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 == 0) {\\n n = n + 128;\\n _num = _num << 128;\\n }\\n if (_num & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 64;\\n _num = _num << 64;\\n }\\n if (_num & 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 32;\\n _num = _num << 32;\\n }\\n if (_num & 0xFFFF000000000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 16;\\n _num = _num << 16;\\n }\\n if (_num & 0xFF00000000000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 8;\\n _num = _num << 8;\\n }\\n if (_num & 0xF000000000000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 4;\\n _num = _num << 4;\\n }\\n if (_num & 0xC000000000000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 2;\\n _num = _num << 2;\\n }\\n if (_num & 0x8000000000000000000000000000000000000000000000000000000000000000 == 0) {\\n n = n + 1;\\n }\\n\\n return n;\\n }\\n}\\n\",\"keccak256\":\"0x3208110a6cde8f74d144dc962c70346ab0d232b613a82ac371f1ab7bcf99cd56\",\"license\":\"Apache-2.0\"},\"@cartesi/util/contracts/MerkleV2.sol\":{\"content\":\"// Copyright 2020 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Library for Merkle proofs\\npragma solidity ^0.8.0;\\n\\nimport \\\"./CartesiMathV2.sol\\\";\\n\\nlibrary MerkleV2 {\\n using CartesiMathV2 for uint256;\\n\\n uint128 constant L_WORD_SIZE = 3; // word = 8 bytes, log = 3\\n // number of hashes in EMPTY_TREE_HASHES\\n uint128 constant EMPTY_TREE_SIZE = 1952; // 61*32=1952. 32 bytes per 61 indexes (64 words)\\n\\n // merkle root hashes of trees of zero concatenated\\n // 32 bytes for each root, first one is keccak(0), second one is\\n // keccak(keccack(0), keccak(0)) and so on\\n\\n bytes constant EMPTY_TREE_HASHES =\\n hex\\\"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce4d9470a821fbe90117ec357e30bad9305732fb19ddf54a07dd3e29f440619254ae39ce8537aca75e2eff3e38c98011dfe934e700a0967732fc07b430dd656a233fc9a15f5b4869c872f81087bb6104b7d63e6f9ab47f2c43f3535eae7172aa7f17d2dd614cddaa4d879276b11e0672c9560033d3e8453a1d045339d34ba601b9c37b8b13ca95166fb7af16988a70fcc90f38bf9126fd833da710a47fb37a55e68e7a427fa943d9966b389f4f257173676090c6e95f43e2cb6d65f8758111e30930b0b9deb73e155c59740bacf14a6ff04b64bb8e201a506409c3fe381ca4ea90cd5deac729d0fdaccc441d09d7325f41586ba13c801b7eccae0f95d8f3933efed8b96e5b7f6f459e9cb6a2f41bf276c7b85c10cd4662c04cbbb365434726c0a0c9695393027fb106a8153109ac516288a88b28a93817899460d6310b71cf1e6163e8806fa0d4b197a259e8c3ac28864268159d0ac85f8581ca28fa7d2c0c03eb91e3eee5ca7a3da2b3053c9770db73599fb149f620e3facef95e947c0ee860b72122e31e4bbd2b7c783d79cc30f60c6238651da7f0726f767d22747264fdb046f7549f26cc70ed5e18baeb6c81bb0625cb95bb4019aeecd40774ee87ae29ec517a71f6ee264c5d761379b3d7d617ca83677374b49d10aec50505ac087408ca892b573c267a712a52e1d06421fe276a03efb1889f337201110fdc32a81f8e152499af665835aabfdc6740c7e2c3791a31c3cdc9f5ab962f681b12fc092816a62f27d86025599a41233848702f0cfc0437b445682df51147a632a0a083d2d38b5e13e466a8935afff58bb533b3ef5d27fba63ee6b0fd9e67ff20af9d50deee3f8bf065ec220c1fd4ba57e341261d55997f85d66d32152526736872693d2b437a233e2337b715f6ac9a6a272622fdc2d67fcfe1da3459f8dab4ed7e40a657a54c36766c5e8ac9a88b35b05c34747e6507f6b044ab66180dc76ac1a696de03189593fedc0d0dbbd855c8ead673544899b0960e4a5a7ca43b4ef90afe607de7698caefdc242788f654b57a4fb32a71b335ef6ff9a4cc118b282b53bdd6d6192b7a82c3c5126b9c7e33c8e5a5ac9738b8bd31247fb7402054f97b573e8abb9faad219f4fd085aceaa7f542d787ee4196d365f3cc566e7bbcfbfd451230c48d804c017d21e2d8fa914e2559bb72bf0ab78c8ab92f00ef0d0d576eccdd486b64138a4172674857e543d1d5b639058dd908186597e366ad5f3d9c7ceaff44d04d1550b8d33abc751df07437834ba5acb32328a396994aebb3c40f759c2d6d7a3cb5377e55d5d218ef5a296dda8ddc355f3f50c3d0b660a51dfa4d98a6a5a33564556cf83c1373a814641d6a1dcef97b883fee61bb84fe60a3409340217e629cc7e4dcc93b85d8820921ff5826148b60e6939acd7838e1d7f20562bff8ee4b5ec4a05ad997a57b9796fdcb2eda87883c2640b072b140b946bfdf6575cacc066fdae04f6951e63624cbd316a677cad529bbe4e97b9144e4bc06c4afd1de55dd3e1175f90423847a230d34dfb71ed56f2965a7f6c72e6aa33c24c303fd67745d632656c5ef90bec80f4f5d1daa251988826cef375c81c36bf457e09687056f924677cb0bccf98dff81e014ce25f2d132497923e267363963cdf4302c5049d63131dc03fd95f65d8b6aa5934f817252c028c90f56d413b9d5d10d89790707dae2fabb249f649929927c21dd71e3f656826de5451c5da375aadecbd59d5ebf3a31fae65ac1b316a1611f1b276b26530f58d7247df459ce1f86db1d734f6f811932f042cee45d0e455306d01081bc3384f82c5fb2aacaa19d89cdfa46cc916eac61121475ba2e6191b4feecbe1789717021a158ace5d06744b40f551076b67cd63af60007f8c99876e1424883a45ec49d497ddaf808a5521ca74a999ab0b3c7aa9c80f85e93977ec61ce68b20307a1a81f71ca645b568fcd319ccbb5f651e87b707d37c39e15f945ea69e2f7c7d2ccc85b7e654c07e96f0636ae4044fe0e38590b431795ad0f8647bdd613713ada493cc17efd313206380e6a685b8198475bbd021c6e9d94daab2214947127506073e44d5408ba166c512a0b86805d07f5a44d3c41706be2bc15e712e55805248b92e8677d90f6d284d1d6ffaff2c430657042a0e82624fa3717b06cc0a6fd12230ea586dae83019fb9e06034ed2803c98d554b93c9a52348cafff75c40174a91f9ae6b8647854a156029f0b88b83316663ce574a4978277bb6bb27a31085634b6ec78864b6d8201c7e93903d75815067e378289a3d072ae172dafa6a452470f8d645bebfad9779594fc0784bb764a22e3a8181d93db7bf97893c414217a618ccb14caa9e92e8c61673afc9583662e812adba1f87a9c68202d60e909efab43c42c0cb00695fc7f1ffe67c75ca894c3c51e1e5e731360199e600f6ced9a87b2a6a87e70bf251bb5075ab222138288164b2eda727515ea7de12e2496d4fe42ea8d1a120c03cf9c50622c2afe4acb0dad98fd62d07ab4e828a94495f6d1ab973982c7ccbe6c1fae02788e4422ae22282fa49cbdb04ba54a7a238c6fc41187451383460762c06d1c8a72b9cd718866ad4b689e10c9a8c38fe5ef045bd785b01e980fc82c7e3532ce81876b778dd9f1ceeba4478e86411fb6fdd790683916ca832592485093644e8760cd7b4c01dba1ccc82b661bf13f0e3f34acd6b88\\\";\\n\\n /// @notice Gets merkle root hash of drive with a replacement\\n /// @param _position position of _drive\\n /// @param _logSizeOfReplacement log2 of size the replacement\\n /// @param _logSizeOfFullDrive log2 of size the full drive, which can be the entire machine\\n /// @param _replacement hash of the replacement\\n /// @param siblings of replacement that merkle root can be calculated\\n function getRootAfterReplacementInDrive(\\n uint256 _position,\\n uint256 _logSizeOfReplacement,\\n uint256 _logSizeOfFullDrive,\\n bytes32 _replacement,\\n bytes32[] calldata siblings\\n ) public pure returns (bytes32) {\\n require(\\n _logSizeOfFullDrive >= _logSizeOfReplacement && _logSizeOfReplacement >= 3 && _logSizeOfFullDrive <= 64,\\n \\\"3 <= logSizeOfReplacement <= logSizeOfFullDrive <= 64\\\"\\n );\\n\\n uint256 size = 1 << _logSizeOfReplacement;\\n\\n require(((size - 1) & _position) == 0, \\\"Position is not aligned\\\");\\n require(siblings.length == _logSizeOfFullDrive - _logSizeOfReplacement, \\\"Proof length does not match\\\");\\n\\n for (uint256 i; i < siblings.length; i++) {\\n if ((_position & (size << i)) == 0) {\\n _replacement = keccak256(abi.encodePacked(_replacement, siblings[i]));\\n } else {\\n _replacement = keccak256(abi.encodePacked(siblings[i], _replacement));\\n }\\n }\\n\\n return _replacement;\\n }\\n\\n /// @notice Gets precomputed hash of zero in empty tree hashes\\n /// @param _index of hash wanted\\n /// @dev first index is keccak(0), second index is keccak(keccak(0), keccak(0))\\n function getEmptyTreeHashAtIndex(uint256 _index) public pure returns (bytes32) {\\n uint256 start = _index * 32;\\n require(EMPTY_TREE_SIZE >= start + 32, \\\"index out of bounds\\\");\\n bytes32 hashedZeros;\\n bytes memory zeroTree = EMPTY_TREE_HASHES;\\n\\n // first word is length, then skip index words\\n assembly {\\n hashedZeros := mload(add(add(zeroTree, 0x20), start))\\n }\\n return hashedZeros;\\n }\\n\\n /// @notice get merkle root of generic array of bytes\\n /// @param _data array of bytes to be merklelized\\n /// @param _log2Size log2 of total size of the drive\\n /// @dev _data is padded with zeroes until is multiple of 8\\n /// @dev root is completed with zero tree until log2size is complete\\n /// @dev hashes are taken word by word (8 bytes by 8 bytes)\\n function getMerkleRootFromBytes(bytes calldata _data, uint256 _log2Size) public pure returns (bytes32) {\\n require(_log2Size >= 3 && _log2Size <= 64, \\\"range of log2Size: [3,64]\\\");\\n\\n // if _data is empty return pristine drive of size log2size\\n if (_data.length == 0) return getEmptyTreeHashAtIndex(_log2Size - 3);\\n\\n // total size of the drive in words\\n uint256 size = 1 << (_log2Size - 3);\\n require(size << L_WORD_SIZE >= _data.length, \\\"data is bigger than drive\\\");\\n // the stack depth is log2(_data.length / 8) + 2\\n uint256 stack_depth = 2 + ((_data.length) >> L_WORD_SIZE).getLog2Floor();\\n bytes32[] memory stack = new bytes32[](stack_depth);\\n\\n uint256 numOfHashes; // total number of hashes on stack (counting levels)\\n uint256 stackLength; // total length of stack\\n uint256 numOfJoins; // number of hashes of the same level on stack\\n uint256 topStackLevel; // hash level of the top of the stack\\n\\n while (numOfHashes < size) {\\n if ((numOfHashes << L_WORD_SIZE) < _data.length) {\\n // we still have words to hash\\n stack[stackLength] = getHashOfWordAtIndex(_data, numOfHashes);\\n numOfHashes++;\\n\\n numOfJoins = numOfHashes;\\n } else {\\n // since padding happens in hashOfWordAtIndex function\\n // we only need to complete the stack with pre-computed\\n // hash(0), hash(hash(0),hash(0)) and so on\\n topStackLevel = numOfHashes.ctz();\\n\\n stack[stackLength] = getEmptyTreeHashAtIndex(topStackLevel);\\n\\n //Empty Tree Hash summarizes many hashes\\n numOfHashes = numOfHashes + (1 << topStackLevel);\\n numOfJoins = numOfHashes >> topStackLevel;\\n }\\n\\n stackLength++;\\n\\n // while there are joins, hash top of stack together\\n while (numOfJoins & 1 == 0) {\\n bytes32 h2 = stack[stackLength - 1];\\n bytes32 h1 = stack[stackLength - 2];\\n\\n stack[stackLength - 2] = keccak256(abi.encodePacked(h1, h2));\\n stackLength = stackLength - 1; // remove hashes from stack\\n\\n numOfJoins = numOfJoins >> 1;\\n }\\n }\\n require(stackLength == 1, \\\"stack error\\\");\\n\\n return stack[0];\\n }\\n\\n /// @notice Get the hash of a word in an array of bytes\\n /// @param _data array of bytes\\n /// @param _wordIndex index of word inside the bytes to get the hash of\\n /// @dev if word is incomplete (< 8 bytes) it gets padded with zeroes\\n function getHashOfWordAtIndex(bytes calldata _data, uint256 _wordIndex) public pure returns (bytes32) {\\n uint256 start = _wordIndex << L_WORD_SIZE;\\n uint256 end = start + (1 << L_WORD_SIZE);\\n\\n // TODO: in .lua this just returns zero, but this might be more consistent\\n require(start <= _data.length, \\\"word out of bounds\\\");\\n\\n if (end <= _data.length) {\\n return keccak256(abi.encodePacked(_data[start:end]));\\n }\\n\\n // word is incomplete\\n // fill paddedSlice with incomplete words - the rest is going to be bytes(0)\\n bytes memory paddedSlice = new bytes(8);\\n uint256 remaining = _data.length - start;\\n\\n for (uint256 i; i < remaining; i++) {\\n paddedSlice[i] = _data[start + i];\\n }\\n\\n return keccak256(paddedSlice);\\n }\\n\\n /// @notice Calculate the root of Merkle tree from an array of power of 2 elements\\n /// @param hashes The array containing power of 2 elements\\n /// @return byte32 the root hash being calculated\\n function calculateRootFromPowerOfTwo(bytes32[] memory hashes) public pure returns (bytes32) {\\n // revert when the input is not of power of 2\\n require((hashes.length).isPowerOf2(), \\\"array len not power of 2\\\");\\n\\n if (hashes.length == 1) {\\n return hashes[0];\\n } else {\\n bytes32[] memory newHashes = new bytes32[](hashes.length >> 1);\\n\\n for (uint256 i; i < hashes.length; i += 2) {\\n newHashes[i >> 1] = keccak256(abi.encodePacked(hashes[i], hashes[i + 1]));\\n }\\n\\n return calculateRootFromPowerOfTwo(newHashes);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x315a8d0fde92e153209207f0ec3aee323bfddc1c6857c5f1e245c781ae98c2b8\",\"license\":\"Apache-2.0\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/OutputFacet.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output facet\\npragma solidity ^0.8.0;\\n\\nimport {Bitmask} from \\\"@cartesi/util/contracts/Bitmask.sol\\\";\\nimport {MerkleV2} from \\\"@cartesi/util/contracts/MerkleV2.sol\\\";\\n\\nimport {IOutput, OutputValidityProof} from \\\"../interfaces/IOutput.sol\\\";\\n\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\ncontract OutputFacet is IOutput {\\n using LibOutput for LibOutput.DiamondStorage;\\n\\n // Here we only need 248 bits as keys in the mapping, but we use 256 bits for gas optimization\\n using Bitmask for mapping(uint256 => uint256);\\n\\n uint256 constant KECCAK_LOG2_SIZE = 5; // keccak log2 size\\n\\n // max size of voucher metadata memory range 32 * (2^16) bytes\\n uint256 constant VOUCHER_METADATA_LOG2_SIZE = 21;\\n // max size of epoch voucher memory range 32 * (2^32) bytes\\n uint256 constant EPOCH_VOUCHER_LOG2_SIZE = 37;\\n\\n // max size of notice metadata memory range 32 * (2^16) bytes\\n uint256 constant NOTICE_METADATA_LOG2_SIZE = 21;\\n // max size of epoch notice memory range 32 * (2^32) bytes\\n uint256 constant EPOCH_NOTICE_LOG2_SIZE = 37;\\n\\n /// @notice functions modified by noReentrancy are not subject to recursion\\n modifier noReentrancy() {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n require(!outputDS.lock, \\\"reentrancy not allowed\\\");\\n outputDS.lock = true;\\n _;\\n outputDS.lock = false;\\n }\\n\\n /// @notice executes voucher\\n /// @param _destination address that will execute the payload\\n /// @param _payload payload to be executed by destination\\n /// @param _v validity proof for this encoded voucher\\n /// @return true if voucher was executed successfully\\n /// @dev vouchers can only be executed once\\n function executeVoucher(\\n address _destination,\\n bytes calldata _payload,\\n OutputValidityProof calldata _v\\n ) public override noReentrancy returns (bool) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n\\n // avoid a malicious DApp developer from draining the Fee Manager's bank account\\n require(_destination != address(feeManagerDS.bank), \\\"bad destination\\\");\\n\\n bytes memory encodedVoucher = abi.encode(_destination, _payload);\\n\\n // check if validity proof matches the voucher provided\\n isValidVoucherProof(\\n encodedVoucher,\\n outputDS.epochHashes[_v.epochIndex],\\n _v\\n );\\n\\n uint256 voucherPosition = getBitMaskPosition(\\n _v.outputIndex,\\n _v.inputIndex,\\n _v.epochIndex\\n );\\n\\n // check if voucher has been executed\\n require(\\n !outputDS.voucherBitmask.getBit(voucherPosition),\\n \\\"re-execution not allowed\\\"\\n );\\n\\n // execute voucher\\n (bool succ, ) = _destination.call(_payload);\\n\\n // if properly executed, mark it as executed and emit event\\n if (succ) {\\n outputDS.voucherBitmask.setBit(voucherPosition, true);\\n emit VoucherExecuted(voucherPosition);\\n }\\n\\n return succ;\\n }\\n\\n /// @notice validates notice\\n /// @param _notice notice to be verified\\n /// @param _v validity proof for this notice\\n /// @return true if notice is valid\\n function validateNotice(\\n bytes calldata _notice,\\n OutputValidityProof calldata _v\\n ) public view override returns (bool) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n bytes memory encodedNotice = abi.encode(_notice);\\n\\n // reverts if validity proof doesnt match\\n isValidNoticeProof(\\n encodedNotice,\\n outputDS.epochHashes[_v.epochIndex],\\n _v\\n );\\n\\n return true;\\n }\\n\\n /// @notice isValidProof reverts if the proof is invalid\\n /// @dev _outputsEpochRootHash must be _v.vouchersEpochRootHash or\\n /// or _v.noticesEpochRootHash\\n function isValidProof(\\n bytes memory _encodedOutput,\\n bytes32 _epochHash,\\n bytes32 _outputsEpochRootHash,\\n uint256 _outputEpochLog2Size,\\n uint256 _outputHashesLog2Size,\\n OutputValidityProof calldata _v\\n ) internal pure {\\n // prove that outputs hash is represented in a finalized epoch\\n require(\\n keccak256(\\n abi.encodePacked(\\n _v.vouchersEpochRootHash,\\n _v.noticesEpochRootHash,\\n _v.machineStateHash\\n )\\n ) == _epochHash,\\n \\\"epochHash incorrect\\\"\\n );\\n\\n // prove that output metadata memory range is contained in epoch's output memory range\\n require(\\n MerkleV2.getRootAfterReplacementInDrive(\\n getIntraDrivePosition(_v.inputIndex, KECCAK_LOG2_SIZE),\\n KECCAK_LOG2_SIZE,\\n _outputEpochLog2Size,\\n _v.outputHashesRootHash,\\n _v.outputHashesInEpochSiblings\\n ) == _outputsEpochRootHash,\\n \\\"outputsEpochRootHash incorrect\\\"\\n );\\n\\n // The hash of the output is converted to bytes (abi.encode) and\\n // treated as data. The metadata output memory range stores that data while\\n // being indifferent to its contents. To prove that the received\\n // output is contained in the metadata output memory range we need to\\n // prove that x, where:\\n // x = keccak(\\n // keccak(\\n // keccak(hashOfOutput[0:7]),\\n // keccak(hashOfOutput[8:15])\\n // ),\\n // keccak(\\n // keccak(hashOfOutput[16:23]),\\n // keccak(hashOfOutput[24:31])\\n // )\\n // )\\n // is contained in it. We can't simply use hashOfOutput because the\\n // log2size of the leaf is three (8 bytes) not five (32 bytes)\\n bytes32 merkleRootOfHashOfOutput = MerkleV2.getMerkleRootFromBytes(\\n abi.encodePacked(keccak256(_encodedOutput)),\\n KECCAK_LOG2_SIZE\\n );\\n\\n // prove that merkle root hash of bytes(hashOfOutput) is contained\\n // in the output metadata array memory range\\n require(\\n MerkleV2.getRootAfterReplacementInDrive(\\n getIntraDrivePosition(_v.outputIndex, KECCAK_LOG2_SIZE),\\n KECCAK_LOG2_SIZE,\\n _outputHashesLog2Size,\\n merkleRootOfHashOfOutput,\\n _v.keccakInHashesSiblings\\n ) == _v.outputHashesRootHash,\\n \\\"outputHashesRootHash incorrect\\\"\\n );\\n }\\n\\n /// @notice isValidVoucherProof reverts if the proof is invalid\\n function isValidVoucherProof(\\n bytes memory _encodedVoucher,\\n bytes32 _epochHash,\\n OutputValidityProof calldata _v\\n ) public pure {\\n isValidProof(\\n _encodedVoucher,\\n _epochHash,\\n _v.vouchersEpochRootHash,\\n EPOCH_VOUCHER_LOG2_SIZE,\\n VOUCHER_METADATA_LOG2_SIZE,\\n _v\\n );\\n }\\n\\n /// @notice isValidNoticeProof reverts if the proof is invalid\\n function isValidNoticeProof(\\n bytes memory _encodedNotice,\\n bytes32 _epochHash,\\n OutputValidityProof calldata _v\\n ) public pure {\\n isValidProof(\\n _encodedNotice,\\n _epochHash,\\n _v.noticesEpochRootHash,\\n EPOCH_NOTICE_LOG2_SIZE,\\n NOTICE_METADATA_LOG2_SIZE,\\n _v\\n );\\n }\\n\\n /// @notice get voucher position on bitmask\\n /// @param _voucher of voucher inside the input\\n /// @param _input which input, inside the epoch, the voucher belongs to\\n /// @param _epoch which epoch the voucher belongs to\\n /// @return position of that voucher on bitmask\\n function getBitMaskPosition(\\n uint256 _voucher,\\n uint256 _input,\\n uint256 _epoch\\n ) public pure returns (uint256) {\\n // voucher * 2 ** 128 + input * 2 ** 64 + epoch\\n // this can't overflow because its impossible to have > 2**128 vouchers\\n return (((_voucher << 128) | (_input << 64)) | _epoch);\\n }\\n\\n /// @notice returns the position of a intra memory range on a memory range\\n // with contents with the same size\\n /// @param _index index of intra memory range\\n /// @param _log2Size of intra memory range\\n function getIntraDrivePosition(\\n uint256 _index,\\n uint256 _log2Size\\n ) public pure returns (uint256) {\\n return (_index << _log2Size);\\n }\\n\\n /// @notice get number of finalized epochs\\n function getNumberOfFinalizedEpochs()\\n public\\n view\\n override\\n returns (uint256)\\n {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n return outputDS.getNumberOfFinalizedEpochs();\\n }\\n\\n /// @notice get log2 size of voucher metadata memory range\\n function getVoucherMetadataLog2Size()\\n public\\n pure\\n override\\n returns (uint256)\\n {\\n return VOUCHER_METADATA_LOG2_SIZE;\\n }\\n\\n /// @notice get log2 size of epoch voucher memory range\\n function getEpochVoucherLog2Size() public pure override returns (uint256) {\\n return EPOCH_VOUCHER_LOG2_SIZE;\\n }\\n\\n /// @notice get log2 size of notice metadata memory range\\n function getNoticeMetadataLog2Size()\\n public\\n pure\\n override\\n returns (uint256)\\n {\\n return NOTICE_METADATA_LOG2_SIZE;\\n }\\n\\n /// @notice get log2 size of epoch notice memory range\\n function getEpochNoticeLog2Size() public pure override returns (uint256) {\\n return EPOCH_NOTICE_LOG2_SIZE;\\n }\\n}\\n\",\"keccak256\":\"0x70f3d2b67fecf7f043bcf3f687e637bbaeb393dd080770f3b51e2589949a578e\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IOutput.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output interface\\npragma solidity >=0.7.0;\\n\\n/// @notice Data used to prove the validity of an output (notices and vouchers)\\n/// @param epochIndex which epoch the output belongs to\\n/// @param inputIndex which input, inside the epoch, the output belongs to\\n/// @param outputIndex index of output inside the input\\n/// @param outputHashesRootHash merkle root of all output metadata hashes of the related input\\n/// @param vouchersEpochRootHash merkle root of all voucher metadata hashes of the related epoch\\n/// @param noticesEpochRootHash merkle root of all notice metadata hashes of the related epoch\\n/// @param machineStateHash hash of the machine state claimed for the related epoch\\n/// @param keccakInHashesSiblings proof that this output metadata is in metadata memory range\\n/// @param outputHashesInEpochSiblings proof that this output metadata is in epoch's output memory range\\nstruct OutputValidityProof {\\n uint256 epochIndex;\\n uint256 inputIndex;\\n uint256 outputIndex;\\n bytes32 outputHashesRootHash;\\n bytes32 vouchersEpochRootHash;\\n bytes32 noticesEpochRootHash;\\n bytes32 machineStateHash;\\n bytes32[] keccakInHashesSiblings;\\n bytes32[] outputHashesInEpochSiblings;\\n}\\n\\ninterface IOutput {\\n /// @notice Executes a voucher\\n /// @param _destination address of the target contract that will execute the payload\\n /// @param _payload payload to be executed by the destination contract, containing a method signature and ABI-encoded parameters\\n /// @param _v validity proof for the voucher\\n /// @return true if voucher was executed successfully\\n /// @dev vouchers can only be successfully executed one time, and only if the provided proof is valid\\n function executeVoucher(\\n address _destination,\\n bytes calldata _payload,\\n OutputValidityProof calldata _v\\n ) external returns (bool);\\n\\n /// @notice Validates a notice\\n /// @param _notice notice to be validated\\n /// @param _v validity proof for the notice\\n /// @return true if notice is valid\\n function validateNotice(\\n bytes calldata _notice,\\n OutputValidityProof calldata _v\\n ) external view returns (bool);\\n\\n /// @notice Get number of finalized epochs\\n function getNumberOfFinalizedEpochs() external view returns (uint256);\\n\\n /// @notice Get log2 size of voucher metadata memory range\\n function getVoucherMetadataLog2Size() external pure returns (uint256);\\n\\n /// @notice Get log2 size of epoch voucher memory range\\n function getEpochVoucherLog2Size() external pure returns (uint256);\\n\\n /// @notice Get log2 size of notice metadata memory range\\n function getNoticeMetadataLog2Size() external pure returns (uint256);\\n\\n /// @notice Get log2 size of epoch notice memory range\\n function getEpochNoticeLog2Size() external pure returns (uint256);\\n\\n /// @notice Indicates that a voucher was executed\\n /// @param voucherPosition voucher unique identifier considering epoch, input and output indices\\n event VoucherExecuted(uint256 voucherPosition);\\n}\\n\",\"keccak256\":\"0xae833978db7f074f365604b19d5f185c1a14f08d1e85fee5319ce368d5e6f723\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610d8e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80636190d81e116100715780636190d81e146101405780638021be811461015357806383552b4d1461015a578063a238203614610181578063a981588a14610153578063f3af7efd1461018157600080fd5b806310517cfc146100ae5780633ad58a27146100d35780633c0d9958146100e85780634f8192c91461010a5780635e439a0c1461012d575b600080fd5b6100c06100bc366004610900565b1b90565b6040519081526020015b60405180910390f35b6100e66100e1366004610951565b610188565b005b6100c06100f6366004610a30565b608083901b604083901b1781179392505050565b61011d610118366004610aa5565b6101a1565b60405190151581526020016100ca565b6100e661013b366004610951565b610227565b61011d61014e366004610af7565b61023b565b60156100c0565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea567546100c0565b60256100c0565b61019c83838360a001356025601586610600565b505050565b6000807f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669050600085856040516020016101dc929190610ba8565b604051602081830303815290604052905061021b818360010186600001358154811061020a5761020a610bc4565b906000526020600020015486610188565b50600195945050505050565b61019c838383608001356025601586610600565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea568546000907f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669060ff16156102d05760405162461bcd60e51b81526020600482015260166024820152751c99595b9d1c985b98de481b9bdd08185b1b1bddd95960521b60448201526064015b60405180910390fd5b60028101805460ff1916600117905560006103087f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea56690565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc75549091507f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc73906001600160a01b039081169089160361039c5760405162461bcd60e51b815260206004820152600f60248201526e3130b2103232b9ba34b730ba34b7b760891b60448201526064016102c7565b60008888886040516020016103b393929190610bda565b60405160208183030381529060405290506103f281846001018860000135815481106103e1576103e1610bc4565b906000526020600020015488610227565b60006020870135604090811b9088013560801b178735176040516303fbaf7360e01b81526004810186905260248101829052909150733F62ccC0e41287ea4d28dce6582a215B75bB43fd906303fbaf7390604401602060405180830381865af4158015610463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190610c08565b156104d45760405162461bcd60e51b815260206004820152601860248201527f72652d657865637574696f6e206e6f7420616c6c6f776564000000000000000060448201526064016102c7565b60008a6001600160a01b03168a8a6040516104f0929190610c31565b6000604051808303816000865af19150503d806000811461052d576040519150601f19603f3d011682016040523d82523d6000602084013e610532565b606091505b5050905080156105e7576040516306449da160e41b8152600481018690526024810183905260016044820152733F62ccC0e41287ea4d28dce6582a215B75bB43fd90636449da109060640160006040518083038186803b15801561059557600080fd5b505af41580156105a9573d6000803e3d6000fd5b505050507f0eb7ee080f865f1cadc4f54daf58cc3b8879e888832867d13351edcec0fbdc54826040516105de91815260200190565b60405180910390a15b955050505050600201805460ff19169055949350505050565b60408051608080840135602083015260a08401359282019290925260c0830135606082015286910160405160208183030381529060405280519060200120146106815760405162461bcd60e51b8152602060048201526013602482015272195c1bd8da12185cda081a5b98dbdc9c9958dd606a1b60448201526064016102c7565b8373353439934aCC3C435A2627954835241ab9FacBF86379de4601602084013560051b60058760608701356106ba610100890189610c41565b6040518763ffffffff1660e01b81526004016106db96959493929190610c8b565b602060405180830381865af41580156106f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071c9190610ce2565b146107695760405162461bcd60e51b815260206004820152601e60248201527f6f75747075747345706f6368526f6f744861736820696e636f7272656374000060448201526064016102c7565b600073353439934aCC3C435A2627954835241ab9FacBF863c84583a1888051906020012060405160200161079f91815260200190565b60405160208183030381529060405260056040518363ffffffff1660e01b81526004016107cd929190610cfb565b602060405180830381865af41580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190610ce2565b9050606082013573353439934aCC3C435A2627954835241ab9FacBF86379de4601604085013560051b6005878661084860e08a018a610c41565b6040518763ffffffff1660e01b815260040161086996959493929190610c8b565b602060405180830381865af4158015610886573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108aa9190610ce2565b146108f75760405162461bcd60e51b815260206004820152601e60248201527f6f7574707574486173686573526f6f744861736820696e636f7272656374000060448201526064016102c7565b50505050505050565b6000806040838503121561091357600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b6000610120828403121561094b57600080fd5b50919050565b60008060006060848603121561096657600080fd5b833567ffffffffffffffff8082111561097e57600080fd5b818601915086601f83011261099257600080fd5b8135818111156109a4576109a4610922565b604051601f8201601f19908116603f011681019083821181831017156109cc576109cc610922565b816040528281528960208487010111156109e557600080fd5b82602086016020830137600060208483010152809750505050602086013593506040860135915080821115610a1957600080fd5b50610a2686828701610938565b9150509250925092565b600080600060608486031215610a4557600080fd5b505081359360208301359350604090920135919050565b60008083601f840112610a6e57600080fd5b50813567ffffffffffffffff811115610a8657600080fd5b602083019150836020828501011115610a9e57600080fd5b9250929050565b600080600060408486031215610aba57600080fd5b833567ffffffffffffffff80821115610ad257600080fd5b610ade87838801610a5c565b90955093506020860135915080821115610a1957600080fd5b60008060008060608587031215610b0d57600080fd5b84356001600160a01b0381168114610b2457600080fd5b9350602085013567ffffffffffffffff80821115610b4157600080fd5b610b4d88838901610a5c565b90955093506040870135915080821115610b6657600080fd5b50610b7387828801610938565b91505092959194509250565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000610bbc602083018486610b7f565b949350505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0384168152604060208201819052600090610bff9083018486610b7f565b95945050505050565b600060208284031215610c1a57600080fd5b81518015158114610c2a57600080fd5b9392505050565b8183823760009101908152919050565b6000808335601e19843603018112610c5857600080fd5b83018035915067ffffffffffffffff821115610c7357600080fd5b6020019150600581901b3603821315610a9e57600080fd5b86815285602082015284604082015283606082015260a060808201528160a0820152600060018060fb1b03831115610cc257600080fd5b8260051b808560c08501376000920160c001918252509695505050505050565b600060208284031215610cf457600080fd5b5051919050565b604081526000835180604084015260005b81811015610d295760208187018101516060868401015201610d0c565b81811115610d3b576000606083860101525b50602083019390935250601f91909101601f19160160600191905056fea2646970667358221220ad5c61aba771b46ff01db2fa849e0f8aa8bcee012d38053cb75c41a9f14b7cdf64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80636190d81e116100715780636190d81e146101405780638021be811461015357806383552b4d1461015a578063a238203614610181578063a981588a14610153578063f3af7efd1461018157600080fd5b806310517cfc146100ae5780633ad58a27146100d35780633c0d9958146100e85780634f8192c91461010a5780635e439a0c1461012d575b600080fd5b6100c06100bc366004610900565b1b90565b6040519081526020015b60405180910390f35b6100e66100e1366004610951565b610188565b005b6100c06100f6366004610a30565b608083901b604083901b1781179392505050565b61011d610118366004610aa5565b6101a1565b60405190151581526020016100ca565b6100e661013b366004610951565b610227565b61011d61014e366004610af7565b61023b565b60156100c0565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea567546100c0565b60256100c0565b61019c83838360a001356025601586610600565b505050565b6000807f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669050600085856040516020016101dc929190610ba8565b604051602081830303815290604052905061021b818360010186600001358154811061020a5761020a610bc4565b906000526020600020015486610188565b50600195945050505050565b61019c838383608001356025601586610600565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea568546000907f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669060ff16156102d05760405162461bcd60e51b81526020600482015260166024820152751c99595b9d1c985b98de481b9bdd08185b1b1bddd95960521b60448201526064015b60405180910390fd5b60028101805460ff1916600117905560006103087f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea56690565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc75549091507f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc73906001600160a01b039081169089160361039c5760405162461bcd60e51b815260206004820152600f60248201526e3130b2103232b9ba34b730ba34b7b760891b60448201526064016102c7565b60008888886040516020016103b393929190610bda565b60405160208183030381529060405290506103f281846001018860000135815481106103e1576103e1610bc4565b906000526020600020015488610227565b60006020870135604090811b9088013560801b178735176040516303fbaf7360e01b8152600481018690526024810182905290915073__$f57eb21c11c6dae369da3ca36f4f48eb77$__906303fbaf7390604401602060405180830381865af4158015610463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190610c08565b156104d45760405162461bcd60e51b815260206004820152601860248201527f72652d657865637574696f6e206e6f7420616c6c6f776564000000000000000060448201526064016102c7565b60008a6001600160a01b03168a8a6040516104f0929190610c31565b6000604051808303816000865af19150503d806000811461052d576040519150601f19603f3d011682016040523d82523d6000602084013e610532565b606091505b5050905080156105e7576040516306449da160e41b815260048101869052602481018390526001604482015273__$f57eb21c11c6dae369da3ca36f4f48eb77$__90636449da109060640160006040518083038186803b15801561059557600080fd5b505af41580156105a9573d6000803e3d6000fd5b505050507f0eb7ee080f865f1cadc4f54daf58cc3b8879e888832867d13351edcec0fbdc54826040516105de91815260200190565b60405180910390a15b955050505050600201805460ff19169055949350505050565b60408051608080840135602083015260a08401359282019290925260c0830135606082015286910160405160208183030381529060405280519060200120146106815760405162461bcd60e51b8152602060048201526013602482015272195c1bd8da12185cda081a5b98dbdc9c9958dd606a1b60448201526064016102c7565b8373__$2a7ef22e717e9afc55afc95d018bf1a85b$__6379de4601602084013560051b60058760608701356106ba610100890189610c41565b6040518763ffffffff1660e01b81526004016106db96959493929190610c8b565b602060405180830381865af41580156106f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071c9190610ce2565b146107695760405162461bcd60e51b815260206004820152601e60248201527f6f75747075747345706f6368526f6f744861736820696e636f7272656374000060448201526064016102c7565b600073__$2a7ef22e717e9afc55afc95d018bf1a85b$__63c84583a1888051906020012060405160200161079f91815260200190565b60405160208183030381529060405260056040518363ffffffff1660e01b81526004016107cd929190610cfb565b602060405180830381865af41580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190610ce2565b9050606082013573__$2a7ef22e717e9afc55afc95d018bf1a85b$__6379de4601604085013560051b6005878661084860e08a018a610c41565b6040518763ffffffff1660e01b815260040161086996959493929190610c8b565b602060405180830381865af4158015610886573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108aa9190610ce2565b146108f75760405162461bcd60e51b815260206004820152601e60248201527f6f7574707574486173686573526f6f744861736820696e636f7272656374000060448201526064016102c7565b50505050505050565b6000806040838503121561091357600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b6000610120828403121561094b57600080fd5b50919050565b60008060006060848603121561096657600080fd5b833567ffffffffffffffff8082111561097e57600080fd5b818601915086601f83011261099257600080fd5b8135818111156109a4576109a4610922565b604051601f8201601f19908116603f011681019083821181831017156109cc576109cc610922565b816040528281528960208487010111156109e557600080fd5b82602086016020830137600060208483010152809750505050602086013593506040860135915080821115610a1957600080fd5b50610a2686828701610938565b9150509250925092565b600080600060608486031215610a4557600080fd5b505081359360208301359350604090920135919050565b60008083601f840112610a6e57600080fd5b50813567ffffffffffffffff811115610a8657600080fd5b602083019150836020828501011115610a9e57600080fd5b9250929050565b600080600060408486031215610aba57600080fd5b833567ffffffffffffffff80821115610ad257600080fd5b610ade87838801610a5c565b90955093506020860135915080821115610a1957600080fd5b60008060008060608587031215610b0d57600080fd5b84356001600160a01b0381168114610b2457600080fd5b9350602085013567ffffffffffffffff80821115610b4157600080fd5b610b4d88838901610a5c565b90955093506040870135915080821115610b6657600080fd5b50610b7387828801610938565b91505092959194509250565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000610bbc602083018486610b7f565b949350505050565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0384168152604060208201819052600090610bff9083018486610b7f565b95945050505050565b600060208284031215610c1a57600080fd5b81518015158114610c2a57600080fd5b9392505050565b8183823760009101908152919050565b6000808335601e19843603018112610c5857600080fd5b83018035915067ffffffffffffffff821115610c7357600080fd5b6020019150600581901b3603821315610a9e57600080fd5b86815285602082015284604082015283606082015260a060808201528160a0820152600060018060fb1b03831115610cc257600080fd5b8260051b808560c08501376000920160c001918252509695505050505050565b600060208284031215610cf457600080fd5b5051919050565b604081526000835180604084015260005b81811015610d295760208187018101516060868401015201610d0c565b81811115610d3b576000606083860101525b50602083019390935250601f91909101601f19160160600191905056fea2646970667358221220ad5c61aba771b46ff01db2fa849e0f8aa8bcee012d38053cb75c41a9f14b7cdf64736f6c634300080d0033", + "libraries": { + "Bitmask": "0x3F62ccC0e41287ea4d28dce6582a215B75bB43fd", + "MerkleV2": "0x353439934aCC3C435A2627954835241ab9FacBF8" + }, + "devdoc": { + "kind": "dev", + "methods": { + "executeVoucher(address,bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "details": "vouchers can only be executed once", + "params": { + "_destination": "address that will execute the payload", + "_payload": "payload to be executed by destination", + "_v": "validity proof for this encoded voucher" + }, + "returns": { + "_0": "true if voucher was executed successfully" + } + }, + "getBitMaskPosition(uint256,uint256,uint256)": { + "params": { + "_epoch": "which epoch the voucher belongs to", + "_input": "which input, inside the epoch, the voucher belongs to", + "_voucher": "of voucher inside the input" + }, + "returns": { + "_0": "position of that voucher on bitmask" + } + }, + "getIntraDrivePosition(uint256,uint256)": { + "params": { + "_index": "index of intra memory range", + "_log2Size": "of intra memory range" + } + }, + "validateNotice(bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "params": { + "_notice": "notice to be verified", + "_v": "validity proof for this notice" + }, + "returns": { + "_0": "true if notice is valid" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "VoucherExecuted(uint256)": { + "notice": "Indicates that a voucher was executed" + } + }, + "kind": "user", + "methods": { + "executeVoucher(address,bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "notice": "executes voucher" + }, + "getBitMaskPosition(uint256,uint256,uint256)": { + "notice": "get voucher position on bitmask" + }, + "getEpochNoticeLog2Size()": { + "notice": "get log2 size of epoch notice memory range" + }, + "getEpochVoucherLog2Size()": { + "notice": "get log2 size of epoch voucher memory range" + }, + "getNoticeMetadataLog2Size()": { + "notice": "get log2 size of notice metadata memory range" + }, + "getNumberOfFinalizedEpochs()": { + "notice": "get number of finalized epochs" + }, + "getVoucherMetadataLog2Size()": { + "notice": "get log2 size of voucher metadata memory range" + }, + "isValidNoticeProof(bytes,bytes32,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "notice": "isValidNoticeProof reverts if the proof is invalid" + }, + "isValidVoucherProof(bytes,bytes32,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "notice": "isValidVoucherProof reverts if the proof is invalid" + }, + "validateNotice(bytes,(uint256,uint256,uint256,bytes32,bytes32,bytes32,bytes32,bytes32[],bytes32[]))": { + "notice": "validates notice" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/OwnershipFacet.json b/onchain/rollups/deployments/gnosis_chiado/OwnershipFacet.json new file mode 100644 index 00000000..6d2d6100 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/OwnershipFacet.json @@ -0,0 +1,105 @@ +{ + "address": "0x19C65463Eb32Ff190062686b4ce150Ea1BD80988", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x239025dfaee97780ba34da32cf20c1666a39f7aaf18366396f680d287044b850", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "179922", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf399c88d50c0d479c6e8cb8ea448f300eaba16d5b71caea2cbe9880136498ae5", + "transactionHash": "0x239025dfaee97780ba34da32cf20c1666a39f7aaf18366396f680d287044b850", + "logs": [], + "blockNumber": 1143557, + "cumulativeGasUsed": "179922", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"returns\":{\"owner_\":\"The address of the owner.\"}},\"transferOwnership(address)\":{\"details\":\"Set _newOwner to address(0) to renounce any ownership.\",\"params\":{\"_newOwner\":\"The address of the new owner of the contract\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"owner()\":{\"notice\":\"Get the address of the owner\"},\"transferOwnership(address)\":{\"notice\":\"Set the address of the new owner of the contract\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/OwnershipFacet.sol\":\"OwnershipFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/facets/OwnershipFacet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport {LibDiamond} from \\\"../libraries/LibDiamond.sol\\\";\\nimport {IERC173} from \\\"../interfaces/IERC173.sol\\\";\\n\\ncontract OwnershipFacet is IERC173 {\\n function transferOwnership(address _newOwner) external override {\\n LibDiamond.enforceIsContractOwner();\\n LibDiamond.setContractOwner(_newOwner);\\n }\\n\\n function owner() external view override returns (address owner_) {\\n owner_ = LibDiamond.contractOwner();\\n }\\n}\\n\",\"keccak256\":\"0x08a198b9541f25536ae7fa16f3de069de7450f66709605911e34834e65ad6419\",\"license\":\"MIT\"},\"contracts/interfaces/IDiamondCut.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\n\\ninterface IDiamondCut {\\n enum FacetCutAction {\\n Add,\\n Replace,\\n Remove\\n }\\n // Add=0, Replace=1, Remove=2\\n\\n struct FacetCut {\\n address facetAddress;\\n FacetCutAction action;\\n bytes4[] functionSelectors;\\n }\\n\\n /// @notice Add/replace/remove any number of functions and optionally execute\\n /// a function with delegatecall\\n /// @param _diamondCut Contains the facet addresses and function selectors\\n /// @param _init The address of the contract or facet to execute _calldata\\n /// @param _calldata A function call, including function selector and arguments\\n /// _calldata is executed with delegatecall on _init\\n function diamondCut(\\n FacetCut[] calldata _diamondCut,\\n address _init,\\n bytes calldata _calldata\\n ) external;\\n\\n event DiamondCut(FacetCut[] diamondCut, address init, bytes callData);\\n}\\n\",\"keccak256\":\"0x6a3129be1f39b6fec871f2c94bf7debf2d6a4e665547a4d83e7f2def38359e44\",\"license\":\"MIT\"},\"contracts/interfaces/IERC173.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/// @title ERC-173 Contract Ownership Standard\\n/// Note: the ERC-165 identifier for this interface is 0x7f5828d0\\n/* is ERC165 */\\ninterface IERC173 {\\n /// @dev This emits when ownership of a contract changes.\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n /// @notice Get the address of the owner\\n /// @return owner_ The address of the owner.\\n function owner() external view returns (address owner_);\\n\\n /// @notice Set the address of the new owner of the contract\\n /// @dev Set _newOwner to address(0) to renounce any ownership.\\n /// @param _newOwner The address of the new owner of the contract\\n function transferOwnership(address _newOwner) external;\\n}\\n\",\"keccak256\":\"0xc47289cda9c9cdb749612eb82ccb9abf9ab08dca74bdca22292ae7f765a15a5f\",\"license\":\"MIT\"},\"contracts/libraries/LibDiamond.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\n/******************************************************************************\\\\\\n* Author: Nick Mudge (https://twitter.com/mudgen)\\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\\n/******************************************************************************/\\nimport {IDiamondCut} from \\\"../interfaces/IDiamondCut.sol\\\";\\n\\nlibrary LibDiamond {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"diamond.standard.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // maps function selectors to the facets that execute the functions.\\n // and maps the selectors to their position in the selectorSlots array.\\n // func selector => address facet, selector position\\n mapping(bytes4 => bytes32) facets;\\n // array of slots of function selectors.\\n // each slot holds 8 function selectors.\\n mapping(uint256 => bytes32) selectorSlots;\\n // The number of function selectors in selectorSlots\\n uint16 selectorCount;\\n // Used to query if a contract implements an interface.\\n // Used to implement ERC-165.\\n mapping(bytes4 => bool) supportedInterfaces;\\n // owner of the contract\\n address contractOwner;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n event OwnershipTransferred(\\n address indexed previousOwner,\\n address indexed newOwner\\n );\\n\\n function setContractOwner(address _newOwner) internal {\\n DiamondStorage storage ds = diamondStorage();\\n address previousOwner = ds.contractOwner;\\n ds.contractOwner = _newOwner;\\n emit OwnershipTransferred(previousOwner, _newOwner);\\n }\\n\\n function contractOwner() internal view returns (address contractOwner_) {\\n contractOwner_ = diamondStorage().contractOwner;\\n }\\n\\n function enforceIsContractOwner() internal view {\\n require(\\n msg.sender == diamondStorage().contractOwner,\\n \\\"LibDiamond: Must be contract owner\\\"\\n );\\n }\\n\\n event DiamondCut(\\n IDiamondCut.FacetCut[] diamondCut,\\n address init,\\n bytes callData\\n );\\n\\n bytes32 constant CLEAR_ADDRESS_MASK =\\n bytes32(uint256(0xffffffffffffffffffffffff));\\n bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));\\n\\n // Internal function version of diamondCut\\n // This code is almost the same as the external diamondCut,\\n // except it is using 'Facet[] memory _diamondCut' instead of\\n // 'Facet[] calldata _diamondCut'.\\n // The code is duplicated to prevent copying calldata to memory which\\n // causes an error for a two dimensional array.\\n function diamondCut(\\n IDiamondCut.FacetCut[] memory _diamondCut,\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n DiamondStorage storage ds = diamondStorage();\\n uint256 originalSelectorCount = ds.selectorCount;\\n uint256 selectorCount = originalSelectorCount;\\n bytes32 selectorSlot;\\n // Check if last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // get last selectorSlot\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n selectorSlot = ds.selectorSlots[selectorCount >> 3];\\n }\\n // loop through diamond cut\\n for (\\n uint256 facetIndex;\\n facetIndex < _diamondCut.length;\\n facetIndex++\\n ) {\\n (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(\\n selectorCount,\\n selectorSlot,\\n _diamondCut[facetIndex].facetAddress,\\n _diamondCut[facetIndex].action,\\n _diamondCut[facetIndex].functionSelectors\\n );\\n }\\n if (selectorCount != originalSelectorCount) {\\n ds.selectorCount = uint16(selectorCount);\\n }\\n // If last selector slot is not full\\n // \\\"selectorCount & 7\\\" is a gas efficient modulo by eight \\\"selectorCount % 8\\\"\\n if (selectorCount & 7 > 0) {\\n // \\\"selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"selectorSlot / 8\\\"\\n ds.selectorSlots[selectorCount >> 3] = selectorSlot;\\n }\\n emit DiamondCut(_diamondCut, _init, _calldata);\\n initializeDiamondCut(_init, _calldata);\\n }\\n\\n function addReplaceRemoveFacetSelectors(\\n uint256 _selectorCount,\\n bytes32 _selectorSlot,\\n address _newFacetAddress,\\n IDiamondCut.FacetCutAction _action,\\n bytes4[] memory _selectors\\n ) internal returns (uint256, bytes32) {\\n DiamondStorage storage ds = diamondStorage();\\n require(\\n _selectors.length > 0,\\n \\\"LibDiamondCut: No selectors in facet to cut\\\"\\n );\\n if (_action == IDiamondCut.FacetCutAction.Add) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Add facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) == address(0),\\n \\\"LibDiamondCut: Can't add function that already exists\\\"\\n );\\n // add facet for selector\\n ds.facets[selector] =\\n bytes20(_newFacetAddress) |\\n bytes32(_selectorCount);\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;\\n // clear selector position in slot and add selector\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |\\n (bytes32(selector) >> selectorInSlotPosition);\\n // if slot is full then write it to storage\\n if (selectorInSlotPosition == 224) {\\n // \\\"_selectorSlot >> 3\\\" is a gas efficient division by 8 \\\"_selectorSlot / 8\\\"\\n ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;\\n _selectorSlot = 0;\\n }\\n _selectorCount++;\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Replace) {\\n enforceHasContractCode(\\n _newFacetAddress,\\n \\\"LibDiamondCut: Replace facet has no code\\\"\\n );\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n address oldFacetAddress = address(bytes20(oldFacet));\\n // only useful if immutable functions exist\\n require(\\n oldFacetAddress != address(this),\\n \\\"LibDiamondCut: Can't replace immutable function\\\"\\n );\\n require(\\n oldFacetAddress != _newFacetAddress,\\n \\\"LibDiamondCut: Can't replace function with same function\\\"\\n );\\n require(\\n oldFacetAddress != address(0),\\n \\\"LibDiamondCut: Can't replace function that doesn't exist\\\"\\n );\\n // replace old facet address\\n ds.facets[selector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(_newFacetAddress);\\n }\\n } else if (_action == IDiamondCut.FacetCutAction.Remove) {\\n require(\\n _newFacetAddress == address(0),\\n \\\"LibDiamondCut: Remove facet address must be address(0)\\\"\\n );\\n // \\\"_selectorCount >> 3\\\" is a gas efficient division by 8 \\\"_selectorCount / 8\\\"\\n uint256 selectorSlotCount = _selectorCount >> 3;\\n // \\\"_selectorCount & 7\\\" is a gas efficient modulo by eight \\\"_selectorCount % 8\\\"\\n uint256 selectorInSlotIndex = _selectorCount & 7;\\n for (\\n uint256 selectorIndex;\\n selectorIndex < _selectors.length;\\n selectorIndex++\\n ) {\\n if (_selectorSlot == 0) {\\n // get last selectorSlot\\n selectorSlotCount--;\\n _selectorSlot = ds.selectorSlots[selectorSlotCount];\\n selectorInSlotIndex = 7;\\n } else {\\n selectorInSlotIndex--;\\n }\\n bytes4 lastSelector;\\n uint256 oldSelectorsSlotCount;\\n uint256 oldSelectorInSlotPosition;\\n // adding a block here prevents stack too deep error\\n {\\n bytes4 selector = _selectors[selectorIndex];\\n bytes32 oldFacet = ds.facets[selector];\\n require(\\n address(bytes20(oldFacet)) != address(0),\\n \\\"LibDiamondCut: Can't remove function that doesn't exist\\\"\\n );\\n // only useful if immutable functions exist\\n require(\\n address(bytes20(oldFacet)) != address(this),\\n \\\"LibDiamondCut: Can't remove immutable function\\\"\\n );\\n // replace selector with last selector in ds.facets\\n // gets the last selector\\n lastSelector = bytes4(\\n _selectorSlot << (selectorInSlotIndex << 5)\\n );\\n if (lastSelector != selector) {\\n // update last selector slot position info\\n ds.facets[lastSelector] =\\n (oldFacet & CLEAR_ADDRESS_MASK) |\\n bytes20(ds.facets[lastSelector]);\\n }\\n delete ds.facets[selector];\\n uint256 oldSelectorCount = uint16(uint256(oldFacet));\\n // \\\"oldSelectorCount >> 3\\\" is a gas efficient division by 8 \\\"oldSelectorCount / 8\\\"\\n oldSelectorsSlotCount = oldSelectorCount >> 3;\\n // \\\"oldSelectorCount & 7\\\" is a gas efficient modulo by eight \\\"oldSelectorCount % 8\\\"\\n oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;\\n }\\n if (oldSelectorsSlotCount != selectorSlotCount) {\\n bytes32 oldSelectorSlot = ds.selectorSlots[\\n oldSelectorsSlotCount\\n ];\\n // clears the selector we are deleting and puts the last selector in its place.\\n oldSelectorSlot =\\n (oldSelectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n // update storage with the modified slot\\n ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;\\n } else {\\n // clears the selector we are deleting and puts the last selector in its place.\\n _selectorSlot =\\n (_selectorSlot &\\n ~(CLEAR_SELECTOR_MASK >>\\n oldSelectorInSlotPosition)) |\\n (bytes32(lastSelector) >> oldSelectorInSlotPosition);\\n }\\n if (selectorInSlotIndex == 0) {\\n delete ds.selectorSlots[selectorSlotCount];\\n _selectorSlot = 0;\\n }\\n }\\n _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;\\n } else {\\n revert(\\\"LibDiamondCut: Incorrect FacetCutAction\\\");\\n }\\n return (_selectorCount, _selectorSlot);\\n }\\n\\n function initializeDiamondCut(\\n address _init,\\n bytes memory _calldata\\n ) internal {\\n if (_init == address(0)) {\\n require(\\n _calldata.length == 0,\\n \\\"LibDiamondCut: _init is address(0) but_calldata is not empty\\\"\\n );\\n } else {\\n require(\\n _calldata.length > 0,\\n \\\"LibDiamondCut: _calldata is empty but _init is not address(0)\\\"\\n );\\n if (_init != address(this)) {\\n enforceHasContractCode(\\n _init,\\n \\\"LibDiamondCut: _init address has no code\\\"\\n );\\n }\\n (bool success, bytes memory error) = _init.delegatecall(_calldata);\\n if (!success) {\\n if (error.length > 0) {\\n // bubble up the error\\n revert(string(error));\\n } else {\\n revert(\\\"LibDiamondCut: _init function reverted\\\");\\n }\\n }\\n }\\n }\\n\\n function enforceHasContractCode(\\n address _contract,\\n string memory _errorMessage\\n ) internal view {\\n uint256 contractSize;\\n assembly {\\n contractSize := extcodesize(_contract)\\n }\\n require(contractSize > 0, _errorMessage);\\n }\\n}\\n\",\"keccak256\":\"0x581eb846bee3d62731f4fc5bf21aa9cf744f491075941de685797f107e5d06f2\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610248806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461005f575b600080fd5b610043610074565b6040516001600160a01b03909116815260200160405180910390f35b61007261006d3660046101e2565b6100ac565b005b60006100a77fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b905090565b6100b46100c0565b6100bd8161014d565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316331461014b5760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b606482015260840160405180910390fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b038481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b6000602082840312156101f457600080fd5b81356001600160a01b038116811461020b57600080fd5b939250505056fea2646970667358221220eae4262b777d15dea997f7bd72219d30a5dfbe4f129ce658f38c2f6db472de0d64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80638da5cb5b1461003b578063f2fde38b1461005f575b600080fd5b610043610074565b6040516001600160a01b03909116815260200160405180910390f35b61007261006d3660046101e2565b6100ac565b005b60006100a77fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b031690565b905090565b6100b46100c0565b6100bd8161014d565b50565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316331461014b5760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b606482015260840160405180910390fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132080546001600160a01b031981166001600160a01b038481169182179093556040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b6000602082840312156101f457600080fd5b81356001600160a01b038116811461020b57600080fd5b939250505056fea2646970667358221220eae4262b777d15dea997f7bd72219d30a5dfbe4f129ce658f38c2f6db472de0d64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "owner()": { + "returns": { + "owner_": "The address of the owner." + } + }, + "transferOwnership(address)": { + "details": "Set _newOwner to address(0) to renounce any ownership.", + "params": { + "_newOwner": "The address of the new owner of the contract" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "owner()": { + "notice": "Get the address of the owner" + }, + "transferOwnership(address)": { + "notice": "Set the address of the new owner of the contract" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/RollupsFacet.json b/onchain/rollups/deployments/gnosis_chiado/RollupsFacet.json new file mode 100644 index 00000000..037979d8 --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/RollupsFacet.json @@ -0,0 +1,292 @@ +{ + "address": "0x98Bd941FFa18D10328eF1dea76a146AB6FD78Ee4", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "claimer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "epochHash", + "type": "bytes32" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "epochHash", + "type": "bytes32" + } + ], + "name": "FinalizeEpoch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Phase", + "name": "newPhase", + "type": "uint8" + } + ], + "name": "PhaseChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "winner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "loser", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "winningClaim", + "type": "bytes32" + } + ], + "name": "ResolveDispute", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeEpoch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getChallengePeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentEpoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentPhase", + "outputs": [ + { + "internalType": "enum Phase", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInputAccumulationStart", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInputDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSealingEpochTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTemplateHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xa84458edaf2689982a3daa20a118fc2250b1f69e26dffeec8a1964b728734c25", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "1330039", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x651fc2f8c5bd006230d5c21abfc110a285e60c02c9385ed0a9c6d2aaa146f120", + "transactionHash": "0xa84458edaf2689982a3daa20a118fc2250b1f69e26dffeec8a1964b728734c25", + "logs": [], + "blockNumber": 1143572, + "cumulativeGasUsed": "1330039", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"claimer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"epochHash\",\"type\":\"bytes32\"}],\"name\":\"FinalizeEpoch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enum Phase\",\"name\":\"newPhase\",\"type\":\"uint8\"}],\"name\":\"PhaseChange\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"winner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"loser\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"winningClaim\",\"type\":\"bytes32\"}],\"name\":\"ResolveDispute\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_epochHash\",\"type\":\"bytes32\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeEpoch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChallengePeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentEpoch\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentPhase\",\"outputs\":[{\"internalType\":\"enum Phase\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInputAccumulationStart\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInputDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSealingEpochTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTemplateHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"claim(bytes32)\":{\"details\":\"ValidatorManager makes sure that msg.sender is allowed and that claim != bytes32(0) TODO: add signatures for aggregated claims\",\"params\":{\"_epochHash\":\"hash of epoch\"}},\"finalizeEpoch()\":{\"details\":\"can only be called if challenge period is over\"},\"getCurrentEpoch()\":{\"details\":\"if phase is input accumulation, then the epoch number is length of finalized epochs array, else there are two non finalized epochs, one awaiting consensus/dispute and another accumulating input\",\"returns\":{\"_0\":\"index of current epoch\"}}},\"version\":1},\"userdoc\":{\"events\":{\"Claim(uint256,address,bytes32)\":{\"notice\":\"claim submitted\"},\"FinalizeEpoch(uint256,bytes32)\":{\"notice\":\"epoch finalized\"},\"PhaseChange(uint8)\":{\"notice\":\"phase change\"},\"ResolveDispute(address,address,bytes32)\":{\"notice\":\"dispute resolved\"}},\"kind\":\"user\",\"methods\":{\"claim(bytes32)\":{\"notice\":\"claim the result of current epoch\"},\"finalizeEpoch()\":{\"notice\":\"finalize epoch after timeout\"},\"getChallengePeriod()\":{\"notice\":\"returns the challenge period in seconds\"},\"getCurrentEpoch()\":{\"notice\":\"returns index of current (accumulating) epoch\"},\"getCurrentPhase()\":{\"notice\":\"returns the current phase\"},\"getInputAccumulationStart()\":{\"notice\":\"returns the input accumulation start timestamp\"},\"getInputDuration()\":{\"notice\":\"returns the input duration in seconds\"},\"getSealingEpochTimestamp()\":{\"notice\":\"returns the sealing epoch timestamp\"},\"getTemplateHash()\":{\"notice\":\"returns the machine's template hash\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/RollupsFacet.sol\":\"RollupsFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/RollupsFacet.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups facet\\npragma solidity ^0.8.0;\\n\\nimport {IRollups, Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\n\\ncontract RollupsFacet is IRollups {\\n ////\\n // All claims agreed OR challenge period ended\\n // functions: claim() or finalizeEpoch()\\n // +--------------------------------------------------+\\n // | |\\n // +--------v-----------+ new input after IPAD +---------+----------+\\n // | +--------------------------->+ |\\n // START ---> | Input Accumulation | firt claim after IPAD | Awaiting Consensus |\\n // | +--------------------------->+ |\\n // +-+------------------+ +-----------------+--+\\n // ^ ^ |\\n // | dispute resolved | |\\n // | dispute resolved before challenge | |\\n // | after challenge +--------------------+ period ended | |\\n // | period ended | +---------------------+ |\\n // +----------------------+ Awaiting Dispute | |\\n // | +<-----------------------+\\n // +--------------------+ conflicting claim\\n ///\\n\\n using LibRollups for LibRollups.DiamondStorage;\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) public override {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n\\n Phase currentPhase = Phase(rollupsDS.currentPhase_int);\\n uint256 inputAccumulationStart = rollupsDS.inputAccumulationStart;\\n uint256 inputDuration = rollupsDS.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n currentPhase = Phase.AwaitingConsensus;\\n rollupsDS.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n\\n // warns input of new epoch\\n inputDS.onNewInputAccumulation();\\n // update timestamp of sealing epoch proposal\\n rollupsDS.sealingEpochTimestamp = uint32(block.timestamp);\\n }\\n\\n require(\\n currentPhase == Phase.AwaitingConsensus,\\n \\\"Phase != AwaitingConsensus\\\"\\n );\\n (result, claims, claimers) = validatorManagerDS.onClaim(\\n payable(msg.sender),\\n _epochHash\\n );\\n\\n // emit the claim event before processing it\\n // so if the epoch is finalized in this claim (consensus)\\n // the number of final epochs doesnt gets contaminated\\n emit Claim(\\n outputDS.getNumberOfFinalizedEpochs(),\\n msg.sender,\\n _epochHash\\n );\\n\\n rollupsDS.resolveValidatorResult(result, claims, claimers);\\n }\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() public override {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n Phase currentPhase = Phase(rollupsDS.currentPhase_int);\\n require(\\n currentPhase == Phase.AwaitingConsensus,\\n \\\"Phase != Awaiting Consensus\\\"\\n );\\n\\n uint256 sealingEpochTimestamp = rollupsDS.sealingEpochTimestamp;\\n uint256 challengePeriod = rollupsDS.challengePeriod;\\n require(\\n block.timestamp > sealingEpochTimestamp + challengePeriod,\\n \\\"Challenge period not over\\\"\\n );\\n\\n require(\\n validatorManagerDS.currentClaim != bytes32(0),\\n \\\"No Claim to be finalized\\\"\\n );\\n\\n rollupsDS.startNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch() public view override returns (uint256) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return rollupsDS.getCurrentEpoch();\\n }\\n\\n /// @notice returns the current phase\\n function getCurrentPhase() public view returns (Phase) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return Phase(rollupsDS.currentPhase_int);\\n }\\n\\n /// @notice returns the input accumulation start timestamp\\n function getInputAccumulationStart() public view returns (uint256) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return uint256(rollupsDS.inputAccumulationStart);\\n }\\n\\n /// @notice returns the sealing epoch timestamp\\n function getSealingEpochTimestamp() public view returns (uint256) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return uint256(rollupsDS.sealingEpochTimestamp);\\n }\\n\\n /// @notice returns the input duration in seconds\\n function getInputDuration() public view returns (uint256) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return uint256(rollupsDS.inputDuration);\\n }\\n\\n /// @notice returns the challenge period in seconds\\n function getChallengePeriod() public view returns (uint256) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return uint256(rollupsDS.challengePeriod);\\n }\\n\\n /// @notice returns the machine's template hash\\n function getTemplateHash() public view returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n return rollupsDS.templateHash;\\n }\\n}\\n\",\"keccak256\":\"0xb4fa1894b1be726ec583569a1027ce9d509528fcb5e1e012228344b5a7343360\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups interface\\npragma solidity >=0.7.0;\\n\\n// InputAccumulation - Inputs being accumulated for currrent epoch\\n// AwaitingConsensus - No disagreeing claims (or no claims)\\n// AwaitingDispute - Waiting for dispute to be over\\n// inputs received during InputAccumulation will be included in the\\n// current epoch. Inputs received while WaitingClaims or ChallengesInProgress\\n// are accumulated for the next epoch\\nenum Phase {\\n InputAccumulation,\\n AwaitingConsensus,\\n AwaitingDispute\\n}\\n\\ninterface IRollups {\\n /// @notice claim the result of current epoch\\n /// @param _epochHash hash of epoch\\n /// @dev ValidatorManager makes sure that msg.sender is allowed\\n /// and that claim != bytes32(0)\\n /// TODO: add signatures for aggregated claims\\n function claim(bytes32 _epochHash) external;\\n\\n /// @notice finalize epoch after timeout\\n /// @dev can only be called if challenge period is over\\n function finalizeEpoch() external;\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two epochs two non\\n /// finalized epochs, one awaiting consensus/dispute and another\\n /// accumulating input\\n function getCurrentEpoch() external view returns (uint256);\\n\\n /// @notice claim submitted\\n /// @param epochHash claim being submitted by this epoch\\n /// @param claimer address of current claimer\\n /// @param epochNumber number of the epoch being submitted\\n event Claim(\\n uint256 indexed epochNumber,\\n address claimer,\\n bytes32 epochHash\\n );\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n}\\n\",\"keccak256\":\"0x241c3ee8bb900067903ac836d5f3ee81eca587c7f225ad6df686478a6b27329b\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibDisputeManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Dispute Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibDisputeManager {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n /// @notice initiates a dispute betweent two players\\n /// @param claims conflicting claims\\n /// @param claimers addresses of senders of conflicting claim\\n /// @dev this is a mock implementation that just gives the win\\n /// to the address in the first posititon of claimers array\\n function initiateDispute(\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n rollupsDS.resolveDispute(claimers[0], claimers[1], claims[0]);\\n }\\n}\\n\",\"keccak256\":\"0x7d3fdb94a17c7f61ef8f6431f42eaa307b30398e3c24093c0526f449752563c9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibInput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Input library\\npragma solidity ^0.8.0;\\n\\nimport {LibRollups} from \\\"../libraries/LibRollups.sol\\\";\\n\\nlibrary LibInput {\\n using LibRollups for LibRollups.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Input.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n // always needs to keep track of two input boxes:\\n // 1 for the input accumulation of next epoch\\n // and 1 for the messages during current epoch. To save gas we alternate\\n // between inputBox0 and inputBox1\\n bytes32[] inputBox0;\\n bytes32[] inputBox1;\\n uint256 inputDriveSize; // size of input flashdrive\\n uint256 currentInputBox;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice get input inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @param index index of input inside that inbox\\n /// @return hash of input at index index\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getInput(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (bytes32) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1[index] : ds.inputBox0[index];\\n }\\n\\n /// @notice get number of inputs inside inbox of currently proposed claim\\n /// @param ds diamond storage pointer\\n /// @return number of inputs on that input box\\n /// @dev currentInputBox being zero means that the inputs for\\n /// the claimed epoch are on input box one\\n function getNumberOfInputs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return\\n ds.currentInputBox == 0 ? ds.inputBox1.length : ds.inputBox0.length;\\n }\\n\\n /// @notice add input to processed by next epoch\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, msg.sender);\\n }\\n\\n /// @notice add internal input to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInternalInput(\\n DiamondStorage storage ds,\\n bytes memory input\\n ) internal returns (bytes32) {\\n return addInputFromSender(ds, input, address(this));\\n }\\n\\n /// @notice add input from a specific sender to processed by next epoch\\n /// @notice this function is to be reserved for internal usage only\\n /// @notice for normal inputs, call `addInput` instead\\n /// @param ds diamond storage pointer\\n /// @param input input to be understood by offchain machine\\n /// @param sender input sender address\\n /// @dev offchain code is responsible for making sure\\n /// that input size is power of 2 and multiple of 8 since\\n /// the offchain machine has a 8 byte word\\n function addInputFromSender(\\n DiamondStorage storage ds,\\n bytes memory input,\\n address sender\\n ) internal returns (bytes32) {\\n LibRollups.DiamondStorage storage rollupsDS = LibRollups\\n .diamondStorage();\\n\\n require(input.length <= ds.inputDriveSize, \\\"input len: [0,driveSize]\\\");\\n\\n // notifyInput returns true if that input\\n // belongs to a new epoch\\n if (rollupsDS.notifyInput()) {\\n swapInputBox(ds);\\n }\\n\\n // points to correct inputBox\\n bytes32[] storage inputBox = ds.currentInputBox == 0\\n ? ds.inputBox0\\n : ds.inputBox1;\\n\\n // get current epoch index\\n uint256 currentEpoch = rollupsDS.getCurrentEpoch();\\n\\n // keccak 64 bytes into 32 bytes\\n bytes32 keccakMetadata = keccak256(\\n abi.encode(\\n sender,\\n block.number,\\n block.timestamp,\\n currentEpoch, // epoch index\\n inputBox.length // input index\\n )\\n );\\n\\n bytes32 keccakInput = keccak256(input);\\n\\n bytes32 inputHash = keccak256(abi.encode(keccakMetadata, keccakInput));\\n\\n // add input to correct inbox\\n inputBox.push(inputHash);\\n\\n emit InputAdded(\\n currentEpoch,\\n inputBox.length - 1,\\n sender,\\n block.timestamp,\\n input\\n );\\n\\n return inputHash;\\n }\\n\\n /// @notice called when a new input accumulation phase begins\\n /// swap inbox to receive inputs for upcoming epoch\\n /// @param ds diamond storage pointer\\n function onNewInputAccumulation(DiamondStorage storage ds) internal {\\n swapInputBox(ds);\\n }\\n\\n /// @notice called when a new epoch begins, clears deprecated inputs\\n /// @param ds diamond storage pointer\\n function onNewEpoch(DiamondStorage storage ds) internal {\\n // clear input box for new inputs\\n // the current input box should be accumulating inputs\\n // for the new epoch already. So we clear the other one.\\n ds.currentInputBox == 0 ? delete ds.inputBox1 : delete ds.inputBox0;\\n }\\n\\n /// @notice changes current input box\\n /// @param ds diamond storage pointer\\n function swapInputBox(DiamondStorage storage ds) internal {\\n ds.currentInputBox = (ds.currentInputBox == 0) ? 1 : 0;\\n }\\n\\n /// @notice input added\\n /// @param epochNumber which epoch this input belongs to\\n /// @param inputIndex index of the input just added\\n /// @param sender msg.sender\\n /// @param timestamp block.timestamp\\n /// @param input input data\\n event InputAdded(\\n uint256 indexed epochNumber,\\n uint256 indexed inputIndex,\\n address sender,\\n uint256 timestamp,\\n bytes input\\n );\\n}\\n\",\"keccak256\":\"0xbef9e65047564508f5b0c800f302d9d0b0757126968baf02e8f84a2563b2830a\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibOutput.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Output library\\npragma solidity ^0.8.0;\\n\\nlibrary LibOutput {\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Output.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n mapping(uint256 => uint256) voucherBitmask;\\n bytes32[] epochHashes;\\n bool lock; //reentrancy lock\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice to be called when an epoch is finalized\\n /// @param ds diamond storage pointer\\n /// @param epochHash hash of finalized epoch\\n /// @dev an epoch being finalized means that its vouchers can be called\\n function onNewEpoch(DiamondStorage storage ds, bytes32 epochHash) internal {\\n ds.epochHashes.push(epochHash);\\n }\\n\\n /// @notice get number of finalized epochs\\n /// @param ds diamond storage pointer\\n function getNumberOfFinalizedEpochs(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.epochHashes.length;\\n }\\n}\\n\",\"keccak256\":\"0xfecf86b891ef3dff302531a042fbcf25c4638cb2cb64497f3c20231cfe04ccf9\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibRollups.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Rollups library\\npragma solidity ^0.8.0;\\n\\nimport {Phase} from \\\"../interfaces/IRollups.sol\\\";\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibInput} from \\\"../libraries/LibInput.sol\\\";\\nimport {LibOutput} from \\\"../libraries/LibOutput.sol\\\";\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibDisputeManager} from \\\"../libraries/LibDisputeManager.sol\\\";\\n\\nlibrary LibRollups {\\n using LibInput for LibInput.DiamondStorage;\\n using LibOutput for LibOutput.DiamondStorage;\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"Rollups.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 templateHash; // state hash of the cartesi machine at t0\\n uint32 inputDuration; // duration of input accumulation phase in seconds\\n uint32 challengePeriod; // duration of challenge period in seconds\\n uint32 inputAccumulationStart; // timestamp when current input accumulation phase started\\n uint32 sealingEpochTimestamp; // timestamp on when a proposed epoch (claim) becomes challengeable\\n uint32 currentPhase_int; // current phase in integer form\\n }\\n\\n /// @notice epoch finalized\\n /// @param epochNumber number of the epoch being finalized\\n /// @param epochHash claim being submitted by this epoch\\n event FinalizeEpoch(uint256 indexed epochNumber, bytes32 epochHash);\\n\\n /// @notice dispute resolved\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n event ResolveDispute(address winner, address loser, bytes32 winningClaim);\\n\\n /// @notice phase change\\n /// @param newPhase new phase\\n event PhaseChange(Phase newPhase);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when new input arrives, manages the phase changes\\n /// @param ds diamond storage pointer\\n /// @dev can only be called by input contract\\n function notifyInput(DiamondStorage storage ds) internal returns (bool) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n uint256 inputAccumulationStart = ds.inputAccumulationStart;\\n uint256 inputDuration = ds.inputDuration;\\n\\n if (\\n currentPhase == Phase.InputAccumulation &&\\n block.timestamp > inputAccumulationStart + inputDuration\\n ) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice called when a dispute is resolved by the dispute manager\\n /// @param ds diamond storage pointer\\n /// @param winner winner of dispute\\n /// @param loser loser of dispute\\n /// @param winningClaim initial claim of winning validator\\n function resolveDispute(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal {\\n Result result;\\n bytes32[2] memory claims;\\n address payable[2] memory claimers;\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n (result, claims, claimers) = validatorManagerDS.onDisputeEnd(\\n winner,\\n loser,\\n winningClaim\\n );\\n\\n // restart challenge period\\n ds.sealingEpochTimestamp = uint32(block.timestamp);\\n\\n emit ResolveDispute(winner, loser, winningClaim);\\n resolveValidatorResult(ds, result, claims, claimers);\\n }\\n\\n /// @notice resolve results returned by validator manager\\n /// @param ds diamond storage pointer\\n /// @param result result from claim or dispute operation\\n /// @param claims array of claims in case of new conflict\\n /// @param claimers array of claimers in case of new conflict\\n function resolveValidatorResult(\\n DiamondStorage storage ds,\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory claimers\\n ) internal {\\n if (result == Result.NoConflict) {\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingConsensus) {\\n ds.currentPhase_int = uint32(Phase.AwaitingConsensus);\\n emit PhaseChange(Phase.AwaitingConsensus);\\n }\\n } else if (result == Result.Consensus) {\\n startNewEpoch(ds);\\n } else {\\n // for the case when result == Result.Conflict\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n if (currentPhase != Phase.AwaitingDispute) {\\n ds.currentPhase_int = uint32(Phase.AwaitingDispute);\\n emit PhaseChange(Phase.AwaitingDispute);\\n }\\n LibDisputeManager.initiateDispute(claims, claimers);\\n }\\n }\\n\\n /// @notice starts new epoch\\n /// @param ds diamond storage pointer\\n function startNewEpoch(DiamondStorage storage ds) internal {\\n LibInput.DiamondStorage storage inputDS = LibInput.diamondStorage();\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n\\n // reset input accumulation start and deactivate challenge period start\\n ds.currentPhase_int = uint32(Phase.InputAccumulation);\\n emit PhaseChange(Phase.InputAccumulation);\\n ds.inputAccumulationStart = uint32(block.timestamp);\\n ds.sealingEpochTimestamp = type(uint32).max;\\n\\n bytes32 finalClaim = validatorManagerDS.onNewEpoch();\\n\\n // emit event before finalized epoch is added to the Output storage\\n emit FinalizeEpoch(outputDS.getNumberOfFinalizedEpochs(), finalClaim);\\n\\n outputDS.onNewEpoch(finalClaim);\\n inputDS.onNewEpoch();\\n }\\n\\n /// @notice returns index of current (accumulating) epoch\\n /// @param ds diamond storage pointer\\n /// @return index of current epoch\\n /// @dev if phase is input accumulation, then the epoch number is length\\n /// of finalized epochs array, else there are two non finalized epochs,\\n /// one awaiting consensus/dispute and another accumulating input\\n function getCurrentEpoch(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n LibOutput.DiamondStorage storage outputDS = LibOutput.diamondStorage();\\n\\n uint256 finalizedEpochs = outputDS.getNumberOfFinalizedEpochs();\\n\\n Phase currentPhase = Phase(ds.currentPhase_int);\\n\\n return\\n currentPhase == Phase.InputAccumulation\\n ? finalizedEpochs\\n : finalizedEpochs + 1;\\n }\\n}\\n\",\"keccak256\":\"0x6455b49596bcc13c3d87869f6795fb747f38efe784f8fc504572f8fb16c00f30\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b5061170f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063a3a40ea511610066578063a3a40ea51461010b578063b97dd9e214610120578063bd66528a14610128578063ddf7bcf01461013b578063e17ba0121461015d57600080fd5b806354ee1da51461009857806361b12c66146100c95780637864b77d146100de57806382ae9ef714610101575b600080fd5b60008051602061165a83398151915254600160601b900463ffffffff165b6040519081526020015b60405180910390f35b6000805160206116ba833981519152546100b6565b60008051602061165a83398151915254640100000000900463ffffffff166100b6565b610109610178565b005b610113610304565b6040516100c091906114fb565b6100b661034b565b61010961013636600461150e565b610365565b60008051602061165a83398151915254600160401b900463ffffffff166100b6565b60008051602061165a8339815191525463ffffffff166100b6565b60008051602061165a833981519152546000805160206116ba8339815191529060008051602061169a83398151915290600090600160801b900463ffffffff1660028111156101c9576101c96114c7565b905060018160028111156101df576101df6114c7565b146102315760405162461bcd60e51b815260206004820152601b60248201527f506861736520213d204177616974696e6720436f6e73656e737573000000000060448201526064015b60405180910390fd5b600183015463ffffffff600160601b8204811691640100000000900416610258818361153d565b42116102a65760405162461bcd60e51b815260206004820152601960248201527f4368616c6c656e676520706572696f64206e6f74206f766572000000000000006044820152606401610228565b83546102f45760405162461bcd60e51b815260206004820152601860248201527f4e6f20436c61696d20746f2062652066696e616c697a656400000000000000006044820152606401610228565b6102fd8561057f565b5050505050565b60008051602061165a833981519152546000906000805160206116ba83398151915290600160801b900463ffffffff166002811115610345576103456114c7565b91505090565b60006000805160206116ba833981519152610345816106b7565b6000805160206116ba8339815191527f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea56660008051602061169a83398151915260006103cf611477565b6103d7611477565b6001870154600090600160801b900463ffffffff1660028111156103fd576103fd6114c7565b600189015490915063ffffffff600160401b8204811691166000836002811115610429576104296114c7565b14801561043e575061043b818361153d565b42115b156104af5760018a8101805463ffffffff60801b1916600160801b17905560405190935060008051602061167a8339815191529061047d9085906114fb565b60405180910390a161048e89610759565b60018a01805463ffffffff60601b1916600160601b4263ffffffff16021790555b60018360028111156104c3576104c36114c7565b146105105760405162461bcd60e51b815260206004820152601a60248201527f506861736520213d204177616974696e67436f6e73656e7375730000000000006044820152606401610228565b61051b87338d610765565b9197509550935061052d886001015490565b60408051338152602081018e90527fd31325e5dc55b03edf08c70299d3b1bc8d4c2ca8512c90138ddd03e3f54fce6c910160405180910390a26105728a878787610986565b5050505050505050505050565b60018101805463ffffffff60801b191690556040517f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff907f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669060008051602061169a8339815191529060008051602061167a83398151915290610604906000906114fb565b60405180910390a160018401805463ffffffff60601b1963ffffffff4216600160401b02166fffffffffffffffff0000000000000000199091161763ffffffff60601b179055600061065582610adc565b9050610662836001015490565b6040518281527f6e3d05bc77b9307d9ba574c7c3196a746edd51104ded1c823edc63be4b8a63c39060200160405180910390a2600180840180549182018155600090815260209020018190556102fd84610b39565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff166002811115610723576107236114c7565b90506000816002811115610739576107396114c7565b1461074e5761074982600161153d565b610750565b815b95945050505050565b61076281610b5c565b50565b600061076f611477565b610777611477565b836107b25760405162461bcd60e51b815260206004820152600b60248201526a656d70747920636c61696d60a81b6044820152606401610228565b6107bc8686610b7b565b6107fd5760405162461bcd60e51b81526020600482015260126024820152711cd95b99195c881b9bdd08185b1b1bddd95960721b6044820152606401610228565b60006108098787610c2a565b600388015490915060f81c811c600116156108765760405162461bcd60e51b815260206004820152602760248201527f73656e6465722068616420636c61696d656420696e20746869732065706f6368604482015266206265666f726560c81b6064820152608401610228565b8654610884578487556108e4565b865485146108e4576108d8600260405180604001604052808a6000015481526020018881525060405180604001604052806108be8c610d09565b6001600160a01b0390811682528b16602090910152610dc3565b9350935093505061097d565b6108ee8787610e1c565b6108f787610e47565b61093b576040805180820182528681526000602080830182905283518085019094526001600160a01b038a168452830181905261093692909190610dc3565b610975565b6040805180820182528681526000602080830182905283518085019094526001600160a01b038a1684528301526109759160019190610dc3565b935093509350505b93509350939050565b600083600281111561099a5761099a6114c7565b03610a24576001840154600090600160801b900463ffffffff1660028111156109c5576109c56114c7565b905060018160028111156109db576109db6114c7565b14610a1e576001858101805463ffffffff60801b1916600160801b17905560405160008051602061167a83398151915291610a15916114fb565b60405180910390a15b50610ad6565b6001836002811115610a3857610a386114c7565b03610a4b57610a468461057f565b610ad6565b6001840154600090600160801b900463ffffffff166002811115610a7157610a716114c7565b90506002816002811115610a8757610a876114c7565b14610acc5760018501805463ffffffff60801b1916600160811b17905560405160008051602061167a83398151915290610ac3906002906114fb565b60405180910390a15b6102fd8383610e69565b50505050565b6000610ae782610e92565b81546000835560038301546001600160f81b031660038401556040518181527fddc860800a99149017c480ec51523bf4143b7215e78956ae5c31e5c568f5383a9060200160405180910390a192915050565b600381015415610b4e57610762816000611495565b610762600182016000611495565b600381015415610b6d576000610b70565b60015b60ff16600390910155565b60006001600160a01b038216610bbf5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b6044820152606401610228565b60005b6001840154811015610c1e57836001018181548110610be357610be3611555565b6000918252602090912001546001600160a01b0390811690841603610c0c576001915050610c24565b80610c168161156b565b915050610bc2565b50600090505b92915050565b60006001600160a01b038216610c6e5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b6044820152606401610228565b60005b6001840154811015610cca57836001018181548110610c9257610c92611555565b6000918252602090912001546001600160a01b0390811690841603610cb8579050610c24565b80610cc28161156b565b915050610c71565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b6044820152606401610228565b600080610d1a836003015460f81c90565b905060005b6001840154811015610d7a576001811b821615610d6857836001018181548110610d4b57610d4b611555565b6000918252602090912001546001600160a01b0316949350505050565b80610d728161156b565b915050610d1f565b5060405162461bcd60e51b815260206004820152601c60248201527f4167726565696e672076616c696461746f72206e6f7420666f756e64000000006044820152606401610228565b6000610dcd611477565b610dd5611477565b7f495383aed97965c56495cdbadedfe9667a1b028c54d3fc4b5335895146e02b70868686604051610e0893929190611584565b60405180910390a150939492935090919050565b6000610e288383610c2a565b6003840154909150610e3a9082610ee7565b8360030181905550505050565b600381015460009060f081901c60ff16610e618260f81c90565b149392505050565b8051602082015183516000805160206116ba83398151915292610e8d928492610f25565b505050565b6000610ea2826003015460f81c90565b905060005b6001830154811015610e8d576001811b821615610ed5576003830154610ecf90826001610fdb565b60038401555b80610edf8161156b565b915050610ea7565b600060088210610f095760405162461bcd60e51b8152600401610228906115f7565b6000610f168360f861153d565b6001901b841791505092915050565b6000610f2f611477565b610f37611477565b60008051602061169a833981519152610f528188888861102e565b60018b01805463ffffffff60601b1916600160601b4263ffffffff1602179055604080516001600160a01b03808d1682528b16602082015290810189905292965090945092507f2afbde4d47160a9c5de25b0df88d5b83e705286f2a447cac162db5e99ad6f5d29060600160405180910390a1610fd188858585610986565b5050505050505050565b600060088310610ffd5760405162461bcd60e51b8152600401610228906115f7565b600061100985856111e2565b90506000611017848361153d565b9050611024868683611230565b9695505050505050565b6000611038611477565b611040611477565b61104a87866112e4565b865484036110e45761105b87610e47565b61109f576040805180820182528581526000602080830182905283518085019094526001600160a01b038a168452830181905261109a929091906113b8565b6110d9565b6040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301526110d991600191906113b8565b9250925092506111d8565b600387015460f81c1561113d576110d9600260405180604001604052808a6000015481526020018781525060405180604001604052806111238c610d09565b6001600160a01b0390811682528b166020909101526113b8565b83875561114a8787610e1c565b61115387610e47565b611197576040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301819052611192929091906113b8565b6111d1565b6040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301526111d191600191906113b8565b9250925092505b9450945094915050565b6000600882106112045760405162461bcd60e51b8152600401610228906115f7565b600061121560016340000000611623565b90508061122384601e61163a565b85901c1691505092915050565b6000600883106112525760405162461bcd60e51b8152600401610228906115f7565b61126160016340000000611623565b8211156112a65760405162461bcd60e51b8152602060048201526013602482015272436c61696d734d61736b204f766572666c6f7760681b6044820152606401610228565b60006112b384601e61163a565b6112c260016340000000611623565b901b1990508481166112d585601e61163a565b9390931b909217949350505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7360005b6001840154811015610ad65783600101818154811061132957611329611555565b6000918252602090912001546001600160a01b03908116908416036113a657600084600101828154811061135f5761135f611555565b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600384015461139790826113fd565b6003850155610a46828261145a565b806113b08161156b565b915050611308565b60006113c2611477565b6113ca611477565b7f09201c193a07cae1df95ae692cc698685574c942a04514c48a4c3249f38594ff868686604051610e0893929190611584565b60006008821061141f5760405162461bcd60e51b8152600401610228906115f7565b82600061142d8460f861153d565b6001901b199182169190506114438460f061153d565b6001901b1991821691905061075082856000611230565b600382015461146b90826000611230565b82600301819055505050565b60405180604001604052806002906020820280368337509192915050565b508054600082559060005260206000209081019061076291905b808211156114c357600081556001016114af565b5090565b634e487b7160e01b600052602160045260246000fd5b6003811061076257634e487b7160e01b600052602160045260246000fd5b60208101611508836114dd565b91905290565b60006020828403121561152057600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561155057611550611527565b500190565b634e487b7160e01b600052603260045260246000fd5b60006001820161157d5761157d611527565b5060010190565b60a08101611591856114dd565b84825260208083018560005b60028110156115ba5781518352918301919083019060010161159d565b505050606083018460005b60028110156115eb5781516001600160a01b0316835291830191908301906001016115c5565b50505050949350505050565b602080825260129082015271696e646578206f7574206f662072616e676560701b604082015260600190565b60008282101561163557611635611527565b500390565b600081600019048311821515161561165457611654611527565b50029056fed32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189ded606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fcd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189ca2646970667358221220dfa28d663e8a5f4685cbe6ced410bf3adbb150ac3d2c9e23be55fbb383f68bd864736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063a3a40ea511610066578063a3a40ea51461010b578063b97dd9e214610120578063bd66528a14610128578063ddf7bcf01461013b578063e17ba0121461015d57600080fd5b806354ee1da51461009857806361b12c66146100c95780637864b77d146100de57806382ae9ef714610101575b600080fd5b60008051602061165a83398151915254600160601b900463ffffffff165b6040519081526020015b60405180910390f35b6000805160206116ba833981519152546100b6565b60008051602061165a83398151915254640100000000900463ffffffff166100b6565b610109610178565b005b610113610304565b6040516100c091906114fb565b6100b661034b565b61010961013636600461150e565b610365565b60008051602061165a83398151915254600160401b900463ffffffff166100b6565b60008051602061165a8339815191525463ffffffff166100b6565b60008051602061165a833981519152546000805160206116ba8339815191529060008051602061169a83398151915290600090600160801b900463ffffffff1660028111156101c9576101c96114c7565b905060018160028111156101df576101df6114c7565b146102315760405162461bcd60e51b815260206004820152601b60248201527f506861736520213d204177616974696e6720436f6e73656e737573000000000060448201526064015b60405180910390fd5b600183015463ffffffff600160601b8204811691640100000000900416610258818361153d565b42116102a65760405162461bcd60e51b815260206004820152601960248201527f4368616c6c656e676520706572696f64206e6f74206f766572000000000000006044820152606401610228565b83546102f45760405162461bcd60e51b815260206004820152601860248201527f4e6f20436c61696d20746f2062652066696e616c697a656400000000000000006044820152606401610228565b6102fd8561057f565b5050505050565b60008051602061165a833981519152546000906000805160206116ba83398151915290600160801b900463ffffffff166002811115610345576103456114c7565b91505090565b60006000805160206116ba833981519152610345816106b7565b6000805160206116ba8339815191527f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea56660008051602061169a83398151915260006103cf611477565b6103d7611477565b6001870154600090600160801b900463ffffffff1660028111156103fd576103fd6114c7565b600189015490915063ffffffff600160401b8204811691166000836002811115610429576104296114c7565b14801561043e575061043b818361153d565b42115b156104af5760018a8101805463ffffffff60801b1916600160801b17905560405190935060008051602061167a8339815191529061047d9085906114fb565b60405180910390a161048e89610759565b60018a01805463ffffffff60601b1916600160601b4263ffffffff16021790555b60018360028111156104c3576104c36114c7565b146105105760405162461bcd60e51b815260206004820152601a60248201527f506861736520213d204177616974696e67436f6e73656e7375730000000000006044820152606401610228565b61051b87338d610765565b9197509550935061052d886001015490565b60408051338152602081018e90527fd31325e5dc55b03edf08c70299d3b1bc8d4c2ca8512c90138ddd03e3f54fce6c910160405180910390a26105728a878787610986565b5050505050505050505050565b60018101805463ffffffff60801b191690556040517f943d5d24442f02461445e15c5d7d4a4ef0acb0d32c5d6f6af37a6882249912ff907f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5669060008051602061169a8339815191529060008051602061167a83398151915290610604906000906114fb565b60405180910390a160018401805463ffffffff60601b1963ffffffff4216600160401b02166fffffffffffffffff0000000000000000199091161763ffffffff60601b179055600061065582610adc565b9050610662836001015490565b6040518281527f6e3d05bc77b9307d9ba574c7c3196a746edd51104ded1c823edc63be4b8a63c39060200160405180910390a2600180840180549182018155600090815260209020018190556102fd84610b39565b7f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea5675460018201546000917f0635ad75fae4d4e8d896461a635d23700076a1c3fd8da26276f18cb1c09ea566918390600160801b900463ffffffff166002811115610723576107236114c7565b90506000816002811115610739576107396114c7565b1461074e5761074982600161153d565b610750565b815b95945050505050565b61076281610b5c565b50565b600061076f611477565b610777611477565b836107b25760405162461bcd60e51b815260206004820152600b60248201526a656d70747920636c61696d60a81b6044820152606401610228565b6107bc8686610b7b565b6107fd5760405162461bcd60e51b81526020600482015260126024820152711cd95b99195c881b9bdd08185b1b1bddd95960721b6044820152606401610228565b60006108098787610c2a565b600388015490915060f81c811c600116156108765760405162461bcd60e51b815260206004820152602760248201527f73656e6465722068616420636c61696d656420696e20746869732065706f6368604482015266206265666f726560c81b6064820152608401610228565b8654610884578487556108e4565b865485146108e4576108d8600260405180604001604052808a6000015481526020018881525060405180604001604052806108be8c610d09565b6001600160a01b0390811682528b16602090910152610dc3565b9350935093505061097d565b6108ee8787610e1c565b6108f787610e47565b61093b576040805180820182528681526000602080830182905283518085019094526001600160a01b038a168452830181905261093692909190610dc3565b610975565b6040805180820182528681526000602080830182905283518085019094526001600160a01b038a1684528301526109759160019190610dc3565b935093509350505b93509350939050565b600083600281111561099a5761099a6114c7565b03610a24576001840154600090600160801b900463ffffffff1660028111156109c5576109c56114c7565b905060018160028111156109db576109db6114c7565b14610a1e576001858101805463ffffffff60801b1916600160801b17905560405160008051602061167a83398151915291610a15916114fb565b60405180910390a15b50610ad6565b6001836002811115610a3857610a386114c7565b03610a4b57610a468461057f565b610ad6565b6001840154600090600160801b900463ffffffff166002811115610a7157610a716114c7565b90506002816002811115610a8757610a876114c7565b14610acc5760018501805463ffffffff60801b1916600160811b17905560405160008051602061167a83398151915290610ac3906002906114fb565b60405180910390a15b6102fd8383610e69565b50505050565b6000610ae782610e92565b81546000835560038301546001600160f81b031660038401556040518181527fddc860800a99149017c480ec51523bf4143b7215e78956ae5c31e5c568f5383a9060200160405180910390a192915050565b600381015415610b4e57610762816000611495565b610762600182016000611495565b600381015415610b6d576000610b70565b60015b60ff16600390910155565b60006001600160a01b038216610bbf5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b6044820152606401610228565b60005b6001840154811015610c1e57836001018181548110610be357610be3611555565b6000918252602090912001546001600160a01b0390811690841603610c0c576001915050610c24565b80610c168161156b565b915050610bc2565b50600090505b92915050565b60006001600160a01b038216610c6e5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b6044820152606401610228565b60005b6001840154811015610cca57836001018181548110610c9257610c92611555565b6000918252602090912001546001600160a01b0390811690841603610cb8579050610c24565b80610cc28161156b565b915050610c71565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b6044820152606401610228565b600080610d1a836003015460f81c90565b905060005b6001840154811015610d7a576001811b821615610d6857836001018181548110610d4b57610d4b611555565b6000918252602090912001546001600160a01b0316949350505050565b80610d728161156b565b915050610d1f565b5060405162461bcd60e51b815260206004820152601c60248201527f4167726565696e672076616c696461746f72206e6f7420666f756e64000000006044820152606401610228565b6000610dcd611477565b610dd5611477565b7f495383aed97965c56495cdbadedfe9667a1b028c54d3fc4b5335895146e02b70868686604051610e0893929190611584565b60405180910390a150939492935090919050565b6000610e288383610c2a565b6003840154909150610e3a9082610ee7565b8360030181905550505050565b600381015460009060f081901c60ff16610e618260f81c90565b149392505050565b8051602082015183516000805160206116ba83398151915292610e8d928492610f25565b505050565b6000610ea2826003015460f81c90565b905060005b6001830154811015610e8d576001811b821615610ed5576003830154610ecf90826001610fdb565b60038401555b80610edf8161156b565b915050610ea7565b600060088210610f095760405162461bcd60e51b8152600401610228906115f7565b6000610f168360f861153d565b6001901b841791505092915050565b6000610f2f611477565b610f37611477565b60008051602061169a833981519152610f528188888861102e565b60018b01805463ffffffff60601b1916600160601b4263ffffffff1602179055604080516001600160a01b03808d1682528b16602082015290810189905292965090945092507f2afbde4d47160a9c5de25b0df88d5b83e705286f2a447cac162db5e99ad6f5d29060600160405180910390a1610fd188858585610986565b5050505050505050565b600060088310610ffd5760405162461bcd60e51b8152600401610228906115f7565b600061100985856111e2565b90506000611017848361153d565b9050611024868683611230565b9695505050505050565b6000611038611477565b611040611477565b61104a87866112e4565b865484036110e45761105b87610e47565b61109f576040805180820182528581526000602080830182905283518085019094526001600160a01b038a168452830181905261109a929091906113b8565b6110d9565b6040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301526110d991600191906113b8565b9250925092506111d8565b600387015460f81c1561113d576110d9600260405180604001604052808a6000015481526020018781525060405180604001604052806111238c610d09565b6001600160a01b0390811682528b166020909101526113b8565b83875561114a8787610e1c565b61115387610e47565b611197576040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301819052611192929091906113b8565b6111d1565b6040805180820182528581526000602080830182905283518085019094526001600160a01b038a1684528301526111d191600191906113b8565b9250925092505b9450945094915050565b6000600882106112045760405162461bcd60e51b8152600401610228906115f7565b600061121560016340000000611623565b90508061122384601e61163a565b85901c1691505092915050565b6000600883106112525760405162461bcd60e51b8152600401610228906115f7565b61126160016340000000611623565b8211156112a65760405162461bcd60e51b8152602060048201526013602482015272436c61696d734d61736b204f766572666c6f7760681b6044820152606401610228565b60006112b384601e61163a565b6112c260016340000000611623565b901b1990508481166112d585601e61163a565b9390931b909217949350505050565b7f844e22529543d6e722c6477171dd50ffe5b412198b92cd9aeea62bbfabe4cc7360005b6001840154811015610ad65783600101818154811061132957611329611555565b6000918252602090912001546001600160a01b03908116908416036113a657600084600101828154811061135f5761135f611555565b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600384015461139790826113fd565b6003850155610a46828261145a565b806113b08161156b565b915050611308565b60006113c2611477565b6113ca611477565b7f09201c193a07cae1df95ae692cc698685574c942a04514c48a4c3249f38594ff868686604051610e0893929190611584565b60006008821061141f5760405162461bcd60e51b8152600401610228906115f7565b82600061142d8460f861153d565b6001901b199182169190506114438460f061153d565b6001901b1991821691905061075082856000611230565b600382015461146b90826000611230565b82600301819055505050565b60405180604001604052806002906020820280368337509192915050565b508054600082559060005260206000209081019061076291905b808211156114c357600081556001016114af565b5090565b634e487b7160e01b600052602160045260246000fd5b6003811061076257634e487b7160e01b600052602160045260246000fd5b60208101611508836114dd565b91905290565b60006020828403121561152057600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561155057611550611527565b500190565b634e487b7160e01b600052603260045260246000fd5b60006001820161157d5761157d611527565b5060010190565b60a08101611591856114dd565b84825260208083018560005b60028110156115ba5781518352918301919083019060010161159d565b505050606083018460005b60028110156115eb5781516001600160a01b0316835291830191908301906001016115c5565b50505050949350505050565b602080825260129082015271696e646578206f7574206f662072616e676560701b604082015260600190565b60008282101561163557611635611527565b500390565b600081600019048311821515161561165457611654611527565b50029056fed32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189ded606d544c2202d032d2626c390923e6f260ca5d89625bba0cfe70d2bdda4e8f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fcd32d7f90491bee81172a406b65f3270d810392fe53bb0379dde8bdd4e624189ca2646970667358221220dfa28d663e8a5f4685cbe6ced410bf3adbb150ac3d2c9e23be55fbb383f68bd864736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "claim(bytes32)": { + "details": "ValidatorManager makes sure that msg.sender is allowed and that claim != bytes32(0) TODO: add signatures for aggregated claims", + "params": { + "_epochHash": "hash of epoch" + } + }, + "finalizeEpoch()": { + "details": "can only be called if challenge period is over" + }, + "getCurrentEpoch()": { + "details": "if phase is input accumulation, then the epoch number is length of finalized epochs array, else there are two non finalized epochs, one awaiting consensus/dispute and another accumulating input", + "returns": { + "_0": "index of current epoch" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "Claim(uint256,address,bytes32)": { + "notice": "claim submitted" + }, + "FinalizeEpoch(uint256,bytes32)": { + "notice": "epoch finalized" + }, + "PhaseChange(uint8)": { + "notice": "phase change" + }, + "ResolveDispute(address,address,bytes32)": { + "notice": "dispute resolved" + } + }, + "kind": "user", + "methods": { + "claim(bytes32)": { + "notice": "claim the result of current epoch" + }, + "finalizeEpoch()": { + "notice": "finalize epoch after timeout" + }, + "getChallengePeriod()": { + "notice": "returns the challenge period in seconds" + }, + "getCurrentEpoch()": { + "notice": "returns index of current (accumulating) epoch" + }, + "getCurrentPhase()": { + "notice": "returns the current phase" + }, + "getInputAccumulationStart()": { + "notice": "returns the input accumulation start timestamp" + }, + "getInputDuration()": { + "notice": "returns the input duration in seconds" + }, + "getSealingEpochTimestamp()": { + "notice": "returns the sealing epoch timestamp" + }, + "getTemplateHash()": { + "notice": "returns the machine's template hash" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/deployments/gnosis_chiado/ValidatorManagerFacet.json b/onchain/rollups/deployments/gnosis_chiado/ValidatorManagerFacet.json new file mode 100644 index 00000000..00302d4e --- /dev/null +++ b/onchain/rollups/deployments/gnosis_chiado/ValidatorManagerFacet.json @@ -0,0 +1,291 @@ +{ + "address": "0x2596c9892cD4c997e6cE22745a2eF8256b0B171f", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Result", + "name": "result", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32[2]", + "name": "claims", + "type": "bytes32[2]" + }, + { + "indexed": false, + "internalType": "address payable[2]", + "name": "validators", + "type": "address[2]" + } + ], + "name": "ClaimReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Result", + "name": "result", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32[2]", + "name": "claims", + "type": "bytes32[2]" + }, + { + "indexed": false, + "internalType": "address payable[2]", + "name": "validators", + "type": "address[2]" + } + ], + "name": "DisputeEnded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "claim", + "type": "bytes32" + } + ], + "name": "NewEpoch", + "type": "event" + }, + { + "inputs": [], + "name": "getAgreementMask", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getConsensusGoalMask", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentClaim", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaxNumValidators", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_sender", + "type": "address" + } + ], + "name": "getNumberOfClaimsByAddress", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + } + ], + "name": "getNumberOfClaimsByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + } + ], + "name": "getValidatorIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xb531884363b6aeead7a4a0935518ca2cce8fb413bfd0120cec0d4a0e8c95602d", + "receipt": { + "to": "0x4e59b44847b379578588920cA78FbF26c0B4956C", + "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", + "contractAddress": null, + "transactionIndex": 0, + "gasUsed": "331464", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf217e25ad78f7b102e7f6b37a35edc4d0cc8016b488f9c454d56f4097d26e1ea", + "transactionHash": "0xb531884363b6aeead7a4a0935518ca2cce8fb413bfd0120cec0d4a0e8c95602d", + "logs": [], + "blockNumber": 1143574, + "cumulativeGasUsed": "331464", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4281d5d8e659c033492a4dfef522eed3", + "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enum Result\",\"name\":\"result\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"bytes32[2]\",\"name\":\"claims\",\"type\":\"bytes32[2]\"},{\"indexed\":false,\"internalType\":\"address payable[2]\",\"name\":\"validators\",\"type\":\"address[2]\"}],\"name\":\"ClaimReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enum Result\",\"name\":\"result\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"bytes32[2]\",\"name\":\"claims\",\"type\":\"bytes32[2]\"},{\"indexed\":false,\"internalType\":\"address payable[2]\",\"name\":\"validators\",\"type\":\"address[2]\"}],\"name\":\"DisputeEnded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"claim\",\"type\":\"bytes32\"}],\"name\":\"NewEpoch\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"getAgreementMask\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getConsensusGoalMask\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentClaim\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMaxNumValidators\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address payable\",\"name\":\"_sender\",\"type\":\"address\"}],\"name\":\"getNumberOfClaimsByAddress\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getNumberOfClaimsByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"}],\"name\":\"getValidatorIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getAgreementMask()\":{\"returns\":{\"_0\":\"current state of agreement mask\"}},\"getConsensusGoalMask()\":{\"returns\":{\"_0\":\"current consensus goal mask\"}},\"getCurrentClaim()\":{\"returns\":{\"_0\":\"current claim\"}},\"getMaxNumValidators()\":{\"returns\":{\"_0\":\"the maximum number of validators\"}},\"getNumberOfClaimsByAddress(address)\":{\"params\":{\"_sender\":\"validator address\"},\"returns\":{\"_0\":\"#claims\"}},\"getNumberOfClaimsByIndex(uint256)\":{\"params\":{\"_index\":\"the index in validator set\"},\"returns\":{\"_0\":\"#claims\"}},\"getValidatorIndex(address)\":{\"params\":{\"_sender\":\"validator address\"},\"returns\":{\"_0\":\"validator index or revert\"}}},\"version\":1},\"userdoc\":{\"events\":{\"ClaimReceived(uint8,bytes32[2],address[2])\":{\"notice\":\"emitted on Claim received\"},\"DisputeEnded(uint8,bytes32[2],address[2])\":{\"notice\":\"emitted on Dispute end\"},\"NewEpoch(bytes32)\":{\"notice\":\"emitted on new Epoch\"}},\"kind\":\"user\",\"methods\":{\"getAgreementMask()\":{\"notice\":\"get agreement mask\"},\"getConsensusGoalMask()\":{\"notice\":\"get consensus goal mask\"},\"getCurrentClaim()\":{\"notice\":\"get current claim\"},\"getMaxNumValidators()\":{\"notice\":\"get the maximum number of validators defined in validator manager\"},\"getNumberOfClaimsByAddress(address)\":{\"notice\":\"get number of claims the sender has made\"},\"getNumberOfClaimsByIndex(uint256)\":{\"notice\":\"get number of claims by the index in the validator set\"},\"getValidatorIndex(address)\":{\"notice\":\"find the validator and return the index or revert\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/facets/ValidatorManagerFacet.sol\":\"ValidatorManagerFacet\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"contracts/IBank.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n// @title Bank interface\\npragma solidity ^0.8.0;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IBank {\\n /// @notice returns the token used internally\\n function getToken() external view returns (IERC20);\\n\\n /// @notice get balance of `_owner`\\n /// @param _owner account owner\\n function balanceOf(address _owner) external view returns (uint256);\\n\\n /// @notice transfer `_value` tokens from bank to `_to`\\n /// @notice decrease the balance of caller by `_value`\\n /// @param _to account that will receive `_value` tokens\\n /// @param _value amount of tokens to be transfered\\n function transferTokens(address _to, uint256 _value) external;\\n\\n /// @notice transfer `_value` tokens from caller to bank\\n /// @notice increase the balance of `_to` by `_value`\\n /// @dev you may need to call `token.approve(bank, _value)`\\n /// @param _to account that will have their balance increased by `_value`\\n /// @param _value amount of tokens to be transfered\\n function depositTokens(address _to, uint256 _value) external;\\n\\n /// @notice `value` tokens were transfered from the bank to `to`\\n /// @notice the balance of `from` was decreased by `value`\\n /// @dev is triggered on any successful call to `transferTokens`\\n /// @param from the account/contract that called `transferTokens` and\\n /// got their balance decreased by `value`\\n /// @param to the one that received `value` tokens from the bank\\n /// @param value amount of tokens that were transfered\\n event Transfer(address indexed from, address to, uint256 value);\\n\\n /// @notice `value` tokens were transfered from `from` to bank\\n /// @notice the balance of `to` was increased by `value`\\n /// @dev is triggered on any successful call to `depositTokens`\\n /// @param from the account/contract that called `depositTokens` and\\n /// transfered `value` tokens to the bank\\n /// @param to the one that got their balance increased by `value`\\n /// @param value amount of tokens that were transfered\\n event Deposit(address from, address indexed to, uint256 value);\\n}\\n\",\"keccak256\":\"0x483dc9b0c26e3a5d43148cf847bd4df2af03438a0d76d60d33549de3ca2dd77d\",\"license\":\"Apache-2.0\"},\"contracts/facets/ValidatorManagerFacet.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager facet\\npragma solidity ^0.8.0;\\n\\nimport {IValidatorManager} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\n\\ncontract ValidatorManagerFacet is IValidatorManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n /// @notice get agreement mask\\n /// @return current state of agreement mask\\n function getAgreementMask() public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.claimsMask.getAgreementMask();\\n }\\n\\n /// @notice get consensus goal mask\\n /// @return current consensus goal mask\\n function getConsensusGoalMask() public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get current claim\\n /// @return current claim\\n function getCurrentClaim() public view override returns (bytes32) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.currentClaim;\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n address payable _sender\\n ) public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.getNumberOfClaimsByAddress(_sender);\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param _sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(address _sender) public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.getValidatorIndex(_sender);\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param _index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n uint256 _index\\n ) public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.getNumberOfClaimsByIndex(_index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @return the maximum number of validators\\n function getMaxNumValidators() public view returns (uint256) {\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n return validatorManagerDS.getMaxNumValidators();\\n }\\n}\\n\",\"keccak256\":\"0xbc65397b7e82c08279ce092d26b85d522994a16caae9fbd426e708d00b577bec\",\"license\":\"Apache-2.0\"},\"contracts/interfaces/IValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager interface\\npragma solidity >=0.7.0;\\n\\n// NoConflict - No conflicting claims or consensus\\n// Consensus - All validators had equal claims\\n// Conflict - Claim is conflicting with previous one\\nenum Result {\\n NoConflict,\\n Consensus,\\n Conflict\\n}\\n\\n// TODO: What is the incentive for validators to not just copy the first claim that arrived?\\ninterface IValidatorManager {\\n /// @notice get current claim\\n function getCurrentClaim() external view returns (bytes32);\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n}\\n\",\"keccak256\":\"0x7eccbaf15dc80cd402459e8c940b0012fd3d3b8d2882fa13798afe92a9ea3b86\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibClaimsMask.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title ClaimsMask library\\npragma solidity >=0.8.8;\\n\\n// ClaimsMask is used to keep track of the number of claims for up to 8 validators\\n// | agreement mask | consensus goal mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n// | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n// In Validator Manager, #claims_validator indicates the #claims the validator has made.\\n// In Fee Manager, #claims_validator indicates the #claims the validator has redeemed. In this case,\\n// agreement mask and consensus goal mask are not used.\\n\\ntype ClaimsMask is uint256;\\n\\nlibrary LibClaimsMask {\\n uint256 constant claimsBitLen = 30; // #bits used for each #claims\\n\\n /// @notice this function creates a new ClaimsMask variable with value _value\\n /// @param _value the value following the format of ClaimsMask\\n function newClaimsMask(uint256 _value) internal pure returns (ClaimsMask) {\\n return ClaimsMask.wrap(_value);\\n }\\n\\n /// @notice this function creates a new ClaimsMask variable with the consensus goal mask set,\\n /// according to the number of validators\\n /// @param _numValidators the number of validators\\n function newClaimsMaskWithConsensusGoalSet(\\n uint256 _numValidators\\n ) internal pure returns (ClaimsMask) {\\n require(_numValidators <= 8, \\\"up to 8 validators\\\");\\n uint256 consensusMask = (1 << _numValidators) - 1;\\n return ClaimsMask.wrap(consensusMask << 240); // 256 - 8 - 8 = 240\\n }\\n\\n /// @notice this function returns the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// this index can be obtained though `getNumberOfClaimsByIndex` function in Validator Manager\\n function getNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (uint256) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 bitmask = (1 << claimsBitLen) - 1;\\n return\\n (ClaimsMask.unwrap(_claimsMask) >>\\n (claimsBitLen * _validatorIndex)) & bitmask;\\n }\\n\\n /// @notice this function increases the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the increase amount\\n function increaseNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 currentNum = getNumClaims(_claimsMask, _validatorIndex);\\n uint256 newNum = currentNum + _value; // overflows checked by default with sol0.8\\n return setNumClaims(_claimsMask, _validatorIndex, newNum);\\n }\\n\\n /// @notice this function sets the #claims for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n /// @param _value the set value\\n function setNumClaims(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex,\\n uint256 _value\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n require(_value <= ((1 << claimsBitLen) - 1), \\\"ClaimsMask Overflow\\\");\\n uint256 bitmask = ~(((1 << claimsBitLen) - 1) <<\\n (claimsBitLen * _validatorIndex));\\n uint256 clearedClaimsMask = ClaimsMask.unwrap(_claimsMask) & bitmask;\\n _claimsMask = ClaimsMask.wrap(\\n clearedClaimsMask | (_value << (claimsBitLen * _validatorIndex))\\n );\\n return _claimsMask;\\n }\\n\\n /// @notice get consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function clearAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (ClaimsMask) {\\n uint256 clearedMask = ClaimsMask.unwrap(_claimsMask) & ((1 << 248) - 1); // 256 - 8 = 248\\n return ClaimsMask.wrap(clearedMask);\\n }\\n\\n /// @notice get the entire agreement mask\\n /// @param _claimsMask the ClaimsMask value\\n function getAgreementMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return (ClaimsMask.unwrap(_claimsMask) >> 248); // get the first 8 bits\\n }\\n\\n /// @notice check if a validator has already claimed\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function alreadyClaimed(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (bool) {\\n // get the first 8 bits. Then & operation on the validator's bit to see if it's set\\n return\\n (((ClaimsMask.unwrap(_claimsMask) >> 248) >> _validatorIndex) &\\n 1) != 0;\\n }\\n\\n /// @notice set agreement mask for the specified validator\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function setAgreementMask(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 setMask = (ClaimsMask.unwrap(_claimsMask) |\\n (1 << (248 + _validatorIndex))); // 256 - 8 = 248\\n return ClaimsMask.wrap(setMask);\\n }\\n\\n /// @notice get the entire consensus goal mask\\n /// @param _claimsMask the ClaimsMask value\\n function getConsensusGoalMask(\\n ClaimsMask _claimsMask\\n ) internal pure returns (uint256) {\\n return ((ClaimsMask.unwrap(_claimsMask) << 8) >> 248); // get the second 8 bits\\n }\\n\\n /// @notice remove validator from the ClaimsMask\\n /// @param _claimsMask the ClaimsMask value\\n /// @param _validatorIndex index of the validator in the validator array, starting from 0\\n function removeValidator(\\n ClaimsMask _claimsMask,\\n uint256 _validatorIndex\\n ) internal pure returns (ClaimsMask) {\\n require(_validatorIndex < 8, \\\"index out of range\\\");\\n uint256 claimsMaskValue = ClaimsMask.unwrap(_claimsMask);\\n // remove validator from agreement bitmask\\n uint256 zeroMask = ~(1 << (_validatorIndex + 248)); // 256 - 8 = 248\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from consensus goal mask\\n zeroMask = ~(1 << (_validatorIndex + 240)); // 256 - 8 - 8 = 240\\n claimsMaskValue = (claimsMaskValue & zeroMask);\\n // remove validator from #claims\\n return\\n setNumClaims(ClaimsMask.wrap(claimsMaskValue), _validatorIndex, 0);\\n }\\n}\\n\",\"keccak256\":\"0x217eb2438f591832d5c61aaf7102c1dbc1feed4ddb871728fc98975ded0e72f2\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibFeeManager.sol\":{\"content\":\"// Copyright 2022 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Fee Manager library\\npragma solidity ^0.8.0;\\n\\nimport {LibValidatorManager} from \\\"../libraries/LibValidatorManager.sol\\\";\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {IBank} from \\\"../IBank.sol\\\";\\n\\nlibrary LibFeeManager {\\n using LibValidatorManager for LibValidatorManager.DiamondStorage;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n using LibClaimsMask for ClaimsMask;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"FeeManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n address owner; // owner of Fee Manager\\n uint256 feePerClaim;\\n IBank bank; // bank that holds the tokens to pay validators\\n bool lock; // reentrancy lock\\n // A bit set used for up to 8 validators.\\n // The first 16 bits are not used to keep compatibility with the validator manager contract.\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | not used | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 16 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask numClaimsRedeemed;\\n }\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n function onlyOwner(DiamondStorage storage ds) internal view {\\n require(ds.owner == msg.sender, \\\"caller is not the owner\\\");\\n }\\n\\n /// @notice this function can be called to check the number of claims that's redeemable for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function numClaimsRedeemable(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 totalClaims = validatorManagerDS.claimsMask.getNumClaims(\\n valIndex\\n );\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n // underflow checked by default with sol0.8\\n // which means if the validator is removed, calling this function will\\n // either return 0 or revert\\n return totalClaims - redeemedClaims;\\n }\\n\\n /// @notice this function can be called to check the number of claims that has been redeemed for the validator\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator\\n function getNumClaimsRedeemed(\\n DiamondStorage storage ds,\\n address _validator\\n ) internal view returns (uint256) {\\n require(_validator != address(0), \\\"address should not be 0\\\");\\n\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n uint256 redeemedClaims = ds.numClaimsRedeemed.getNumClaims(valIndex);\\n\\n return redeemedClaims;\\n }\\n\\n /// @notice contract owner can reset the value of fee per claim\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _value the new value of fee per claim\\n function resetFeePerClaim(\\n DiamondStorage storage ds,\\n uint256 _value\\n ) internal {\\n // before resetting the feePerClaim, pay fees for all validators as per current rates\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n for (\\n uint256 valIndex;\\n valIndex < validatorManagerDS.maxNumValidators;\\n valIndex++\\n ) {\\n address validator = validatorManagerDS.validators[valIndex];\\n if (validator != address(0)) {\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(validator);\\n if (nowRedeemingClaims > 0) {\\n ds.numClaimsRedeemed = ds\\n .numClaimsRedeemed\\n .increaseNumClaims(valIndex, nowRedeemingClaims);\\n\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(validator, nowRedeemingClaims);\\n }\\n }\\n }\\n ds.feePerClaim = _value;\\n emit FeePerClaimReset(_value);\\n }\\n\\n /// @notice this function can be called to redeem fees for validators\\n /// @param ds pointer to FeeManager's diamond storage\\n /// @param _validator address of the validator that is redeeming\\n function redeemFee(DiamondStorage storage ds, address _validator) internal {\\n // follow the Checks-Effects-Interactions pattern for security\\n\\n // ** checks **\\n uint256 nowRedeemingClaims = ds.numClaimsRedeemable(_validator);\\n require(nowRedeemingClaims > 0, \\\"nothing to redeem yet\\\");\\n\\n // ** effects **\\n LibValidatorManager.DiamondStorage\\n storage validatorManagerDS = LibValidatorManager.diamondStorage();\\n uint256 valIndex = validatorManagerDS.getValidatorIndex(_validator); // will revert if not found\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.increaseNumClaims(\\n valIndex,\\n nowRedeemingClaims\\n );\\n\\n // ** interactions **\\n uint256 feesToSend = nowRedeemingClaims * ds.feePerClaim; // number of erc20 tokens to send\\n ds.bank.transferTokens(_validator, feesToSend); // will revert if transfer fails\\n // emit the number of claimed being redeemed, instead of the amount of tokens\\n emit FeeRedeemed(_validator, nowRedeemingClaims);\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param index index of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal {\\n ds.numClaimsRedeemed = ds.numClaimsRedeemed.setNumClaims(index, 0);\\n }\\n\\n /// @notice emitted on resetting feePerClaim\\n event FeePerClaimReset(uint256 value);\\n\\n /// @notice emitted on ERC20 funds redeemed by validator\\n event FeeRedeemed(address validator, uint256 claims);\\n}\\n\",\"keccak256\":\"0x00f83789adb64fe2b18a7fa96c9f3e73043226bd8b3ec6887349ae4021d8e6ca\",\"license\":\"Apache-2.0\"},\"contracts/libraries/LibValidatorManager.sol\":{\"content\":\"// Copyright 2021 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: Apache-2.0\\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\"); you may not use\\n// this file except in compliance with the License. You may obtain a copy of the\\n// License at http://www.apache.org/licenses/LICENSE-2.0\\n\\n// Unless required by applicable law or agreed to in writing, software distributed\\n// under the License is distributed on an \\\"AS IS\\\" BASIS, WITHOUT WARRANTIES OR\\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\\n// specific language governing permissions and limitations under the License.\\n\\n/// @title Validator Manager library\\npragma solidity ^0.8.0;\\n\\nimport {Result} from \\\"../interfaces/IValidatorManager.sol\\\";\\n\\nimport {LibClaimsMask, ClaimsMask} from \\\"../libraries/LibClaimsMask.sol\\\";\\nimport {LibFeeManager} from \\\"../libraries/LibFeeManager.sol\\\";\\n\\nlibrary LibValidatorManager {\\n using LibClaimsMask for ClaimsMask;\\n using LibFeeManager for LibFeeManager.DiamondStorage;\\n\\n bytes32 constant DIAMOND_STORAGE_POSITION =\\n keccak256(\\\"ValidatorManager.diamond.storage\\\");\\n\\n struct DiamondStorage {\\n bytes32 currentClaim; // current claim - first claim of this epoch\\n address payable[] validators; // up to 8 validators\\n uint256 maxNumValidators; // the maximum number of validators, set in the constructor\\n // A bit set used for up to 8 validators.\\n // The first 8 bits are used to indicate whom supports the current claim\\n // The second 8 bits are used to indicate those should have claimed in order to reach consensus\\n // The following every 30 bits are used to indicate the number of total claims each validator has made\\n // | agreement mask | consensus mask | #claims_validator7 | #claims_validator6 | ... | #claims_validator0 |\\n // | 8 bits | 8 bits | 30 bits | 30 bits | ... | 30 bits |\\n ClaimsMask claimsMask;\\n }\\n\\n /// @notice emitted on Claim received\\n event ClaimReceived(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on Dispute end\\n event DisputeEnded(\\n Result result,\\n bytes32[2] claims,\\n address payable[2] validators\\n );\\n\\n /// @notice emitted on new Epoch\\n event NewEpoch(bytes32 claim);\\n\\n function diamondStorage()\\n internal\\n pure\\n returns (DiamondStorage storage ds)\\n {\\n bytes32 position = DIAMOND_STORAGE_POSITION;\\n assembly {\\n ds.slot := position\\n }\\n }\\n\\n /// @notice called when a dispute ends in rollups\\n /// @param ds diamond storage pointer\\n /// @param winner address of dispute winner\\n /// @param loser address of dispute loser\\n /// @param winningClaim the winnning claim\\n /// @return result of dispute being finished\\n function onDisputeEnd(\\n DiamondStorage storage ds,\\n address payable winner,\\n address payable loser,\\n bytes32 winningClaim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n removeValidator(ds, loser);\\n\\n if (winningClaim == ds.currentClaim) {\\n // first claim stood, dont need to update the bitmask\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n // if first claim lost, and other validators have agreed with it\\n // there is a new dispute to be played\\n if (ds.claimsMask.getAgreementMask() != 0) {\\n return\\n emitDisputeEndedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, winningClaim],\\n [getClaimerOfCurrentClaim(ds), winner]\\n );\\n }\\n // else there are no valdiators that agree with losing claim\\n // we can update current claim and check for consensus in case\\n // the winner is the only validator left\\n ds.currentClaim = winningClaim;\\n updateClaimAgreementMask(ds, winner);\\n return\\n isConsensus(ds)\\n ? emitDisputeEndedAndReturn(\\n Result.Consensus,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n )\\n : emitDisputeEndedAndReturn(\\n Result.NoConflict,\\n [winningClaim, bytes32(0)],\\n [winner, payable(0)]\\n );\\n }\\n\\n /// @notice called when a new epoch starts\\n /// @param ds diamond storage pointer\\n /// @return current claim\\n function onNewEpoch(DiamondStorage storage ds) internal returns (bytes32) {\\n // reward validators who has made the correct claim by increasing their #claims\\n claimFinalizedIncreaseCounts(ds);\\n\\n bytes32 tmpClaim = ds.currentClaim;\\n\\n // clear current claim\\n ds.currentClaim = bytes32(0);\\n // clear validator agreement bit mask\\n ds.claimsMask = ds.claimsMask.clearAgreementMask();\\n\\n emit NewEpoch(tmpClaim);\\n return tmpClaim;\\n }\\n\\n /// @notice called when a claim is received by rollups\\n /// @param ds diamond storage pointer\\n /// @param sender address of sender of that claim\\n /// @param claim claim received by rollups\\n /// @return result of claim, Consensus | NoConflict | Conflict\\n /// @return [currentClaim, conflicting claim] if there is Conflict\\n /// [currentClaim, bytes32(0)] if there is Consensus or NoConflcit\\n /// @return [claimer1, claimer2] if there is Conflcit\\n /// [claimer1, address(0)] if there is Consensus or NoConflcit\\n function onClaim(\\n DiamondStorage storage ds,\\n address payable sender,\\n bytes32 claim\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n require(claim != bytes32(0), \\\"empty claim\\\");\\n require(isValidator(ds, sender), \\\"sender not allowed\\\");\\n\\n // require the validator hasn't claimed in the same epoch before\\n uint256 index = getValidatorIndex(ds, sender);\\n require(\\n !ds.claimsMask.alreadyClaimed(index),\\n \\\"sender had claimed in this epoch before\\\"\\n );\\n\\n // cant return because a single claim might mean consensus\\n if (ds.currentClaim == bytes32(0)) {\\n ds.currentClaim = claim;\\n } else if (claim != ds.currentClaim) {\\n return\\n emitClaimReceivedAndReturn(\\n Result.Conflict,\\n [ds.currentClaim, claim],\\n [getClaimerOfCurrentClaim(ds), sender]\\n );\\n }\\n updateClaimAgreementMask(ds, sender);\\n\\n return\\n isConsensus(ds)\\n ? emitClaimReceivedAndReturn(\\n Result.Consensus,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n )\\n : emitClaimReceivedAndReturn(\\n Result.NoConflict,\\n [claim, bytes32(0)],\\n [sender, payable(0)]\\n );\\n }\\n\\n /// @notice emits dispute ended event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitDisputeEndedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit DisputeEnded(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice emits claim received event and then return\\n /// @param result to be emitted and returned\\n /// @param claims to be emitted and returned\\n /// @param validators to be emitted and returned\\n /// @dev this function existis to make code more clear/concise\\n function emitClaimReceivedAndReturn(\\n Result result,\\n bytes32[2] memory claims,\\n address payable[2] memory validators\\n ) internal returns (Result, bytes32[2] memory, address payable[2] memory) {\\n emit ClaimReceived(result, claims, validators);\\n return (result, claims, validators);\\n }\\n\\n /// @notice only call this function when a claim has been finalized\\n /// Either a consensus has been reached or challenge period has past\\n /// @param ds pointer to diamond storage\\n function claimFinalizedIncreaseCounts(DiamondStorage storage ds) internal {\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n // if a validator agrees with the current claim\\n if ((agreementMask & (1 << i)) != 0) {\\n // increase #claims by 1\\n ds.claimsMask = ds.claimsMask.increaseNumClaims(i, 1);\\n }\\n }\\n }\\n\\n /// @notice removes a validator\\n /// @param ds diamond storage pointer\\n /// @param validator address of validator to be removed\\n function removeValidator(\\n DiamondStorage storage ds,\\n address validator\\n ) internal {\\n LibFeeManager.DiamondStorage storage feeManagerDS = LibFeeManager\\n .diamondStorage();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (validator == ds.validators[i]) {\\n // put address(0) in validators position\\n ds.validators[i] = payable(0);\\n // remove the validator from ValidatorManager's claimsMask\\n ds.claimsMask = ds.claimsMask.removeValidator(i);\\n // remove the validator from FeeManager's claimsMask (#redeems)\\n feeManagerDS.removeValidator(i);\\n break;\\n }\\n }\\n }\\n\\n /// @notice check if consensus has been reached\\n /// @param ds pointer to diamond storage\\n function isConsensus(\\n DiamondStorage storage ds\\n ) internal view returns (bool) {\\n ClaimsMask claimsMask = ds.claimsMask;\\n return\\n claimsMask.getAgreementMask() == claimsMask.getConsensusGoalMask();\\n }\\n\\n /// @notice get one of the validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @return validator that agreed with current claim\\n function getClaimerOfCurrentClaim(\\n DiamondStorage storage ds\\n ) internal view returns (address payable) {\\n // TODO: we are always getting the first validator\\n // on the array that agrees with the current claim to enter a dispute\\n // should this be random?\\n uint256 agreementMask = ds.claimsMask.getAgreementMask();\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (agreementMask & (1 << i) != 0) {\\n return ds.validators[i];\\n }\\n }\\n revert(\\\"Agreeing validator not found\\\");\\n }\\n\\n /// @notice updates mask of validators that agreed with current claim\\n /// @param ds diamond storage pointer\\n /// @param sender address of validator that will be included in mask\\n function updateClaimAgreementMask(\\n DiamondStorage storage ds,\\n address payable sender\\n ) internal {\\n uint256 validatorIndex = getValidatorIndex(ds, sender);\\n ds.claimsMask = ds.claimsMask.setAgreementMask(validatorIndex);\\n }\\n\\n /// @notice check if the sender is a validator\\n /// @param ds pointer to diamond storage\\n /// @param sender sender address\\n function isValidator(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (bool) {\\n require(sender != address(0), \\\"address 0\\\");\\n\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return true;\\n }\\n\\n return false;\\n }\\n\\n /// @notice find the validator and return the index or revert\\n /// @param ds pointer to diamond storage\\n /// @param sender validator address\\n /// @return validator index or revert\\n function getValidatorIndex(\\n DiamondStorage storage ds,\\n address sender\\n ) internal view returns (uint256) {\\n require(sender != address(0), \\\"address 0\\\");\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (sender == ds.validators[i]) return i;\\n }\\n revert(\\\"validator not found\\\");\\n }\\n\\n /// @notice get number of claims the sender has made\\n /// @param ds pointer to diamond storage\\n /// @param _sender validator address\\n /// @return #claims\\n function getNumberOfClaimsByAddress(\\n DiamondStorage storage ds,\\n address payable _sender\\n ) internal view returns (uint256) {\\n for (uint256 i; i < ds.validators.length; i++) {\\n if (_sender == ds.validators[i]) {\\n return getNumberOfClaimsByIndex(ds, i);\\n }\\n }\\n // if validator not found\\n return 0;\\n }\\n\\n /// @notice get number of claims by the index in the validator set\\n /// @param ds pointer to diamond storage\\n /// @param index the index in validator set\\n /// @return #claims\\n function getNumberOfClaimsByIndex(\\n DiamondStorage storage ds,\\n uint256 index\\n ) internal view returns (uint256) {\\n return ds.claimsMask.getNumClaims(index);\\n }\\n\\n /// @notice get the maximum number of validators defined in validator manager\\n /// @param ds pointer to diamond storage\\n /// @return the maximum number of validators\\n function getMaxNumValidators(\\n DiamondStorage storage ds\\n ) internal view returns (uint256) {\\n return ds.maxNumValidators;\\n }\\n}\\n\",\"keccak256\":\"0x14acffee6376e0ea2ca258c4ff60e9b29c162b2bcd11f2d5c3ad50698aebff2c\",\"license\":\"Apache-2.0\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610506806100206000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638219fda41161005b5780638219fda4146100c2578063cc8a2451146100d7578063d2992f54146100ea578063f6023815146100f257600080fd5b8063101494ce146100825780631fcc449e1461009c57806355564a70146100af575b600080fd5b61008a6100fa565b60405190815260200160405180910390f35b61008a6100aa3660046103ff565b610139565b61008a6100bd3660046103ff565b61015b565b6000805160206104b18339815191525461008a565b61008a6100e536600461041c565b610176565b61008a610191565b61008a6101cb565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1ff546000906000805160206104b18339815191529060f81c5b91505090565b60006000805160206104b1833981519152610154818461020b565b9392505050565b60006000805160206104b183398151915261015481846102f5565b60006000805160206104b18339815191526101548184610367565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fe546000906000805160206104b183398151915290610133565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1ff546000906000805160206104b18339815191529060f01c60ff16610133565b60006001600160a01b0382166102545760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b60448201526064015b60405180910390fd5b60005b60018401548110156102b05783600101818154811061027857610278610435565b6000918252602090912001546001600160a01b039081169084160361029e5790506102ef565b806102a881610461565b915050610257565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b604482015260640161024b565b92915050565b6000805b600184015481101561035d5783600101818154811061031a5761031a610435565b6000918252602090912001546001600160a01b039081169084160361034b576103438482610367565b9150506102ef565b8061035581610461565b9150506102f9565b5060009392505050565b600382015460009061015490836000600882106103bb5760405162461bcd60e51b8152602060048201526012602482015271696e646578206f7574206f662072616e676560701b604482015260640161024b565b60006103cc6001634000000061047a565b9050806103da84601e610491565b85901c1691505092915050565b6001600160a01b03811681146103fc57600080fd5b50565b60006020828403121561041157600080fd5b8135610154816103e7565b60006020828403121561042e57600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016104735761047361044b565b5060010190565b60008282101561048c5761048c61044b565b500390565b60008160001904831182151516156104ab576104ab61044b565b50029056fe8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fca2646970667358221220fd400eda940152213df247b2e985745ea7e642c73f890ac0824697ecd173f0da64736f6c634300080d0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80638219fda41161005b5780638219fda4146100c2578063cc8a2451146100d7578063d2992f54146100ea578063f6023815146100f257600080fd5b8063101494ce146100825780631fcc449e1461009c57806355564a70146100af575b600080fd5b61008a6100fa565b60405190815260200160405180910390f35b61008a6100aa3660046103ff565b610139565b61008a6100bd3660046103ff565b61015b565b6000805160206104b18339815191525461008a565b61008a6100e536600461041c565b610176565b61008a610191565b61008a6101cb565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1ff546000906000805160206104b18339815191529060f81c5b91505090565b60006000805160206104b1833981519152610154818461020b565b9392505050565b60006000805160206104b183398151915261015481846102f5565b60006000805160206104b18339815191526101548184610367565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fe546000906000805160206104b183398151915290610133565b7f8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1ff546000906000805160206104b18339815191529060f01c60ff16610133565b60006001600160a01b0382166102545760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b60448201526064015b60405180910390fd5b60005b60018401548110156102b05783600101818154811061027857610278610435565b6000918252602090912001546001600160a01b039081169084160361029e5790506102ef565b806102a881610461565b915050610257565b5060405162461bcd60e51b81526020600482015260136024820152721d985b1a59185d1bdc881b9bdd08199bdd5b99606a1b604482015260640161024b565b92915050565b6000805b600184015481101561035d5783600101818154811061031a5761031a610435565b6000918252602090912001546001600160a01b039081169084160361034b576103438482610367565b9150506102ef565b8061035581610461565b9150506102f9565b5060009392505050565b600382015460009061015490836000600882106103bb5760405162461bcd60e51b8152602060048201526012602482015271696e646578206f7574206f662072616e676560701b604482015260640161024b565b60006103cc6001634000000061047a565b9050806103da84601e610491565b85901c1691505092915050565b6001600160a01b03811681146103fc57600080fd5b50565b60006020828403121561041157600080fd5b8135610154816103e7565b60006020828403121561042e57600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016104735761047361044b565b5060010190565b60008282101561048c5761048c61044b565b500390565b60008160001904831182151516156104ab576104ab61044b565b50029056fe8ab37fef2b2e34c4b62ff9948ee661cdcf34e209d7c20f4d1f6e83085e93b1fca2646970667358221220fd400eda940152213df247b2e985745ea7e642c73f890ac0824697ecd173f0da64736f6c634300080d0033", + "devdoc": { + "kind": "dev", + "methods": { + "getAgreementMask()": { + "returns": { + "_0": "current state of agreement mask" + } + }, + "getConsensusGoalMask()": { + "returns": { + "_0": "current consensus goal mask" + } + }, + "getCurrentClaim()": { + "returns": { + "_0": "current claim" + } + }, + "getMaxNumValidators()": { + "returns": { + "_0": "the maximum number of validators" + } + }, + "getNumberOfClaimsByAddress(address)": { + "params": { + "_sender": "validator address" + }, + "returns": { + "_0": "#claims" + } + }, + "getNumberOfClaimsByIndex(uint256)": { + "params": { + "_index": "the index in validator set" + }, + "returns": { + "_0": "#claims" + } + }, + "getValidatorIndex(address)": { + "params": { + "_sender": "validator address" + }, + "returns": { + "_0": "validator index or revert" + } + } + }, + "version": 1 + }, + "userdoc": { + "events": { + "ClaimReceived(uint8,bytes32[2],address[2])": { + "notice": "emitted on Claim received" + }, + "DisputeEnded(uint8,bytes32[2],address[2])": { + "notice": "emitted on Dispute end" + }, + "NewEpoch(bytes32)": { + "notice": "emitted on new Epoch" + } + }, + "kind": "user", + "methods": { + "getAgreementMask()": { + "notice": "get agreement mask" + }, + "getConsensusGoalMask()": { + "notice": "get consensus goal mask" + }, + "getCurrentClaim()": { + "notice": "get current claim" + }, + "getMaxNumValidators()": { + "notice": "get the maximum number of validators defined in validator manager" + }, + "getNumberOfClaimsByAddress(address)": { + "notice": "get number of claims the sender has made" + }, + "getNumberOfClaimsByIndex(uint256)": { + "notice": "get number of claims by the index in the validator set" + }, + "getValidatorIndex(address)": { + "notice": "find the validator and return the index or revert" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/onchain/rollups/export/abi/gnosis_chiado.json b/onchain/rollups/export/abi/gnosis_chiado.json new file mode 100644 index 00000000..d2323b60 --- /dev/null +++ b/onchain/rollups/export/abi/gnosis_chiado.json @@ -0,0 +1,3831 @@ +{ + "name": "gnosis_chiado", + "chainId": "10200", + "contracts": { + "Bank": { + "address": "0x6F3582233305B6D30A34f5fE44BDF78681E32cfA", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "depositTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "transferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "CartesiDAppFactory": { + "address": "0x617E418c50Bf5941C9D6eBA3caE5EcD3bC19356A", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IDiamondCut", + "name": "diamondCutFacet", + "type": "address" + }, + { + "internalType": "contract DiamondInit", + "name": "diamondInit", + "type": "address" + }, + { + "internalType": "contract IBank", + "name": "feeManagerBank", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "diamondCut", + "type": "tuple[]" + } + ], + "internalType": "struct CartesiDAppFactory.FactoryConfig", + "name": "_fConfig", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract CartesiDApp", + "name": "application", + "type": "address" + }, + { + "components": [ + { + "internalType": "address", + "name": "diamondOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "indexed": false, + "internalType": "struct ICartesiDAppFactory.AppConfig", + "name": "config", + "type": "tuple" + } + ], + "name": "ApplicationCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "diamondCut", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "diamondCutFacet", + "outputs": [ + { + "internalType": "contract IDiamondCut", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "diamondInit", + "outputs": [ + { + "internalType": "contract DiamondInit", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeManagerBank", + "outputs": [ + { + "internalType": "contract IBank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "diamondOwner", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "internalType": "struct ICartesiDAppFactory.AppConfig", + "name": "_appConfig", + "type": "tuple" + } + ], + "name": "newApplication", + "outputs": [ + { + "internalType": "contract CartesiDApp", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "DiamondCutFacet": { + "address": "0x10dc33852b996A4C8A391d6Ed224FD89A3aD1ceE", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "DiamondInit": { + "address": "0xCbEDAB3193dc8027cc403a01cE054695a08E2F34", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "feeManagerBank", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + } + ], + "name": "FeeManagerInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + } + ], + "name": "RollupsInitialized", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "templateHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "inputDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "challengePeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputLog2Size", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feePerClaim", + "type": "uint256" + }, + { + "internalType": "address", + "name": "feeManagerBank", + "type": "address" + }, + { + "internalType": "address", + "name": "feeManagerOwner", + "type": "address" + }, + { + "internalType": "address payable[]", + "name": "validators", + "type": "address[]" + } + ], + "internalType": "struct DiamondConfig", + "name": "_dConfig", + "type": "tuple" + } + ], + "name": "init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "DiamondLoupeFacet": { + "address": "0x8339b06c37d488d51aB838f6C758D61ddb1F1C6c", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "facetFunctionSelectors_", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondLoupe.Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "ERC20PortalFacet": { + "address": "0x0328426f3cf581F1Cf5Ba3492a3d1C5AB551de62", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC20", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ERC20Deposited", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_ERC20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "erc20Deposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "ERC721PortalFacet": { + "address": "0xCF8E4cb394805b96290FEcE429E98613aB80b1c3", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC721", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ERC721Received", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "ERC721", + "type": "address" + }, + { + "indexed": false, + "internalType": "address payable", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ERC721Withdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "erc721Withdrawal", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "EtherPortalFacet": { + "address": "0x1ab5f2688Faec8Dd89e0E2BF23506dB4A4EE5eCA", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "EtherDeposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address payable", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "EtherWithdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "etherDeposit", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "etherWithdrawal", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "FeeManagerFacet": { + "address": "0x81823BDB8ae08E546AD1eCcDa910Ab32B7253343", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "FeePerClaimReset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "claims", + "type": "uint256" + } + ], + "name": "FeeRedeemed", + "type": "event" + }, + { + "inputs": [], + "name": "getFeeManagerBank", + "outputs": [ + { + "internalType": "contract IBank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "getNumClaimsRedeemed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "numClaimsRedeemable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "redeemFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "resetFeePerClaim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "InputFacet": { + "address": "0xeA8538B194742b992B19e694C13D63120908880e", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "input", + "type": "bytes" + } + ], + "name": "InputAdded", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_input", + "type": "bytes" + } + ], + "name": "addInput", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentInbox", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + } + ], + "name": "getInput", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNumberOfInputs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "OutputFacet": { + "address": "0x3E1944bB826391e0F47EC96147c20B931BDA5372", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "voucherPosition", + "type": "uint256" + } + ], + "name": "VoucherExecuted", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_destination", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_payload", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "executeVoucher", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_voucher", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_input", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_epoch", + "type": "uint256" + } + ], + "name": "getBitMaskPosition", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getEpochNoticeLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getEpochVoucherLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_log2Size", + "type": "uint256" + } + ], + "name": "getIntraDrivePosition", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getNoticeMetadataLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getNumberOfFinalizedEpochs", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVoucherMetadataLog2Size", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_encodedNotice", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "isValidNoticeProof", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_encodedVoucher", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "isValidVoucherProof", + "outputs": [], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_notice", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "epochIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "inputIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "outputHashesRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vouchersEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "noticesEpochRootHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "machineStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "keccakInHashesSiblings", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "outputHashesInEpochSiblings", + "type": "bytes32[]" + } + ], + "internalType": "struct OutputValidityProof", + "name": "_v", + "type": "tuple" + } + ], + "name": "validateNotice", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "OwnershipFacet": { + "address": "0x19C65463Eb32Ff190062686b4ce150Ea1BD80988", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "RollupsFacet": { + "address": "0x98Bd941FFa18D10328eF1dea76a146AB6FD78Ee4", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "claimer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "epochHash", + "type": "bytes32" + } + ], + "name": "Claim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epochNumber", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "epochHash", + "type": "bytes32" + } + ], + "name": "FinalizeEpoch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Phase", + "name": "newPhase", + "type": "uint8" + } + ], + "name": "PhaseChange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "winner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "loser", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "winningClaim", + "type": "bytes32" + } + ], + "name": "ResolveDispute", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_epochHash", + "type": "bytes32" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeEpoch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getChallengePeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentEpoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentPhase", + "outputs": [ + { + "internalType": "enum Phase", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInputAccumulationStart", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInputDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSealingEpochTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTemplateHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "ValidatorManagerFacet": { + "address": "0x2596c9892cD4c997e6cE22745a2eF8256b0B171f", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Result", + "name": "result", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32[2]", + "name": "claims", + "type": "bytes32[2]" + }, + { + "indexed": false, + "internalType": "address payable[2]", + "name": "validators", + "type": "address[2]" + } + ], + "name": "ClaimReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "enum Result", + "name": "result", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32[2]", + "name": "claims", + "type": "bytes32[2]" + }, + { + "indexed": false, + "internalType": "address payable[2]", + "name": "validators", + "type": "address[2]" + } + ], + "name": "DisputeEnded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "claim", + "type": "bytes32" + } + ], + "name": "NewEpoch", + "type": "event" + }, + { + "inputs": [], + "name": "getAgreementMask", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getConsensusGoalMask", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentClaim", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaxNumValidators", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_sender", + "type": "address" + } + ], + "name": "getNumberOfClaimsByAddress", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + } + ], + "name": "getNumberOfClaimsByIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + } + ], + "name": "getValidatorIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "Bitmask": { + "address": "0x3F62ccC0e41287ea4d28dce6582a215B75bB43fd", + "abi": [] + }, + "BitsManipulation": { + "address": "0x91E780568A1FEdd5d01E1c1E4cAed68E3a849345", + "abi": [ + { + "inputs": [ + { + "internalType": "int32", + "name": "number", + "type": "int32" + }, + { + "internalType": "uint32", + "name": "wordSize", + "type": "uint32" + } + ], + "name": "int32SignExtension", + "outputs": [ + { + "internalType": "int32", + "name": "", + "type": "int32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "num", + "type": "uint32" + } + ], + "name": "uint32SwapEndian", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "number", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "wordSize", + "type": "uint64" + } + ], + "name": "uint64SignExtension", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "num", + "type": "uint64" + } + ], + "name": "uint64SwapEndian", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "BitsManipulationLibrary": { + "address": "0x302311FF8A135c0FC8703Cb4769EAa1604A4A515", + "abi": [ + { + "inputs": [ + { + "internalType": "int32", + "name": "number", + "type": "int32" + }, + { + "internalType": "uint32", + "name": "wordSize", + "type": "uint32" + } + ], + "name": "int32SignExtension", + "outputs": [ + { + "internalType": "int32", + "name": "", + "type": "int32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "num", + "type": "uint32" + } + ], + "name": "uint32SwapEndian", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "number", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "wordSize", + "type": "uint64" + } + ], + "name": "uint64SignExtension", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "num", + "type": "uint64" + } + ], + "name": "uint64SwapEndian", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "CartesiMathV2": { + "address": "0x7db3A9BdA16D1C295b23B94a61808EFf82288269", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "clz", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "ctz", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "getLog2Floor", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "getLog2TableTimes1M", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "isPowerOf2", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "log2ApproxTimes1M", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "Merkle": { + "address": "0x7CD2b2F951BAc762BF7affd73689A3e1198596AB", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "hashes", + "type": "bytes32[]" + } + ], + "name": "calculateRootFromPowerOfTwo", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "name": "getLog2Floor", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_log2Size", + "type": "uint8" + } + ], + "name": "getPristineHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "_position", + "type": "uint64" + }, + { + "internalType": "bytes8", + "name": "_value", + "type": "bytes8" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "getRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "_position", + "type": "uint64" + }, + { + "internalType": "uint8", + "name": "_logOfSize", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_drive", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "name": "getRootWithDrive", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "name": "isPowerOf2", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "MerkleV2": { + "address": "0x353439934aCC3C435A2627954835241ab9FacBF8", + "abi": [ + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "hashes", + "type": "bytes32[]" + } + ], + "name": "calculateRootFromPowerOfTwo", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_index", + "type": "uint256" + } + ], + "name": "getEmptyTreeHashAtIndex", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_wordIndex", + "type": "uint256" + } + ], + "name": "getHashOfWordAtIndex", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_log2Size", + "type": "uint256" + } + ], + "name": "getMerkleRootFromBytes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_position", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_logSizeOfReplacement", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_logSizeOfFullDrive", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_replacement", + "type": "bytes32" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "name": "getRootAfterReplacementInDrive", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "UnrolledCordic": { + "address": "0x9F7EBA84FfED559c7C63Bdf4DB6a1C6eB763ffb3", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "val", + "type": "uint256" + } + ], + "name": "log2Times1e18", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } + ] + }, + "WorkerAuthManagerImpl": { + "address": "0x50bEFaEfD3AAaFac11Fd936A8dfEB1050eC5Cf00", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_workerManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dapp", + "type": "address" + } + ], + "name": "Authorization", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dapp", + "type": "address" + } + ], + "name": "Deauthorization", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "deauthorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "getOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "isAuthorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "WorkerManagerAuthManagerImpl": { + "address": "0x89f1f1bc37Ef872ff0073bee7eE6d6B0D94Fd166", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dapp", + "type": "address" + } + ], + "name": "Authorization", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dapp", + "type": "address" + } + ], + "name": "Deauthorization", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobAccepted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobOffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobRejected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Retired", + "type": "event" + }, + { + "inputs": [], + "name": "acceptJob", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "cancelHire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "deauthorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "getOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "getUser", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "hire", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "hireAndAuthorize", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_dappAddress", + "type": "address" + } + ], + "name": "isAuthorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "workerAddress", + "type": "address" + } + ], + "name": "isAvailable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "isOwned", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "workerAddress", + "type": "address" + } + ], + "name": "isPending", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "isRetired", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rejectJob", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "retire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "WorkerManagerImpl": { + "address": "0xdeCac9ff6b588642887414e85dfdDE740A797F56", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobAccepted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobOffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "JobRejected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "worker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Retired", + "type": "event" + }, + { + "inputs": [], + "name": "acceptJob", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "cancelHire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "getOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "getUser", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "hire", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "workerAddress", + "type": "address" + } + ], + "name": "isAvailable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "isOwned", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "workerAddress", + "type": "address" + } + ], + "name": "isPending", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "isRetired", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rejectJob", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_workerAddress", + "type": "address" + } + ], + "name": "retire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "CartesiToken": { + "address": "0x4F046BE54AA9f542887d504e8EA8551286B7ba31", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "sender", + "type": "address" + }, + { + "name": "recipient", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DECIMALS", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "INITIAL_SUPPLY", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "account", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_extraLockTime", + "type": "uint256" + } + ], + "name": "extendMintLockTime", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "addMinter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceMinter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "NAME", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "recipient", + "type": "address" + }, + { + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "account", + "type": "address" + } + ], + "name": "isMinter", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "SYMBOL", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "extendedBy", + "type": "uint256" + }, + { + "indexed": false, + "name": "deadline", + "type": "uint256" + } + ], + "name": "LocktimeExteded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "account", + "type": "address" + } + ], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "account", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + } + ] + } + } +} \ No newline at end of file diff --git a/onchain/rollups/hardhat.config.ts b/onchain/rollups/hardhat.config.ts index a5be0590..1828ac8e 100644 --- a/onchain/rollups/hardhat.config.ts +++ b/onchain/rollups/hardhat.config.ts @@ -57,6 +57,12 @@ const config: HardhatUserConfig = { polygon_mumbai: infuraNetwork("polygon-mumbai", 80001), arbitrum_goerli: infuraNetwork("arbitrum-goerli", 421613), optimism_goerli: infuraNetwork("optimism-goerli", 420), + gnosis_chiado: { + url: "https://rpc.chiadochain.net", + chainId: 10200, + gasPrice: 1000000000, + accounts: mnemonic ? { mnemonic } : undefined, + }, }, solidity: { version: "0.8.13", @@ -115,6 +121,10 @@ const config: HardhatUserConfig = { ppath("@cartesi/util", "/deployments/optimism_goerli"), ppath("@cartesi/token", "/deployments/optimism_goerli"), ], + gnosis_chiado: [ + ppath("@cartesi/util", "/deployments/gnosis_chiado"), + ppath("@cartesi/token", "/deployments/gnosis_chiado"), + ], }, }, namedAccounts: { diff --git a/onchain/rollups/package.json b/onchain/rollups/package.json index 4abea066..73b0af90 100644 --- a/onchain/rollups/package.json +++ b/onchain/rollups/package.json @@ -1,6 +1,6 @@ { "name": "@cartesi/rollups", - "version": "0.8.0", + "version": "0.8.1", "scripts": { "build": "run-s compile export", "clean:ignored": "rimraf artifacts cache coverage deployments/localhost dist generated-src src/types/*", @@ -16,6 +16,7 @@ "deploy:polygon_mumbai": "hardhat deploy --network polygon_mumbai --export export/abi/polygon_mumbai.json", "deploy:arbitrum_goerli": "hardhat deploy --network arbitrum_goerli --export export/abi/arbitrum_goerli.json", "deploy:optimism_goerli": "hardhat deploy --network optimism_goerli --export export/abi/optimism_goerli.json", + "deploy:gnosis_chiado": "hardhat deploy --network gnosis_chiado --export export/abi/gnosis_chiado.json", "export": "hardhat export-artifacts export/artifacts --hide-sources --including-empty-bytecode --including-no-public-functions", "info": "npm-scripts-info", "prepack": "run-s build tsc:prod copy-dts", @@ -28,7 +29,7 @@ "tsc:prod": "tsc -p tsconfig.prod.json" }, "dependencies": { - "@cartesi/token": "^1.7.1", + "@cartesi/token": "^1.8.0", "@cartesi/util": "^5.0.1", "@openzeppelin/contracts": "^4.7.1" }, diff --git a/onchain/yarn.lock b/onchain/yarn.lock index db210795..9c11d720 100644 --- a/onchain/yarn.lock +++ b/onchain/yarn.lock @@ -23,10 +23,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@cartesi/token@^1.7.1": - version "1.7.1" - resolved "https://registry.yarnpkg.com/@cartesi/token/-/token-1.7.1.tgz#9ffdd8479ea2688fc7de44fa42fe913806f94a52" - integrity sha512-y9LQFtJLs67aGQkNF5jrvAV+gkOXzBav01rONN2wLN0DOdYRwq+3YYSL3Z0iZWqEZ8fOg0H2gTEshVTPTDS0QA== +"@cartesi/token@^1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@cartesi/token/-/token-1.8.0.tgz#1f19bda1c5bd4e9e784cbd671c096e0333f11fb3" + integrity sha512-jcr1ItbEjvhfy0A5KjOwLUd8Yqawo+F7o6p+9sxqfi1RYa39jTL1qhbF9xui4dR7slVrTwqWQTRHHwlfSHzq8A== dependencies: "@openzeppelin/contracts" "^2.5.0"