UNPKG

@cartesi/arbitration

Version:
628 lines 87.5 kB
{ "address": "0x7925A01C44eC8206F03435847503C65C6d1A5ab4", "abi": [ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "FinishedProofs", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "FinishedReplay", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" }, { "indexed": false, "internalType": "bytes32", "name": "_initialHash", "type": "bytes32" } ], "name": "MemoryCreated", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" }, { "indexed": false, "internalType": "bool", "name": "_wasRead", "type": "bool" }, { "indexed": false, "internalType": "uint64", "name": "_position", "type": "uint64" }, { "indexed": false, "internalType": "bytes8", "name": "_value", "type": "bytes8" } ], "name": "ValueProved", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" }, { "indexed": false, "internalType": "uint64", "name": "_position", "type": "uint64" }, { "indexed": false, "internalType": "bytes8", "name": "_value", "type": "bytes8" } ], "name": "ValueRead", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "_index", "type": "uint256" }, { "indexed": false, "internalType": "uint64", "name": "_position", "type": "uint64" }, { "indexed": false, "internalType": "bytes8", "name": "_value", "type": "bytes8" } ], "name": "ValueWritten", "type": "event" }, { "inputs": [], "name": "currentIndex", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "finishProofPhase", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "finishReplayPhase", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "getCurrentState", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" }, { "internalType": "uint256", "name": "_roundDuration", "type": "uint256" }, { "internalType": "uint256", "name": "_timeToStartMachine", "type": "uint256" } ], "name": "getCurrentStateDeadline", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_roundDuration", "type": "uint256" }, { "internalType": "uint256", "name": "_timeToStartMachine", "type": "uint256" } ], "name": "getMaxInstanceDuration", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "getNonce", "outputs": [ { "internalType": "uint256", "name": "currentNonce", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "getRWArrays", "outputs": [ { "internalType": "uint64[]", "name": "", "type": "uint64[]" }, { "internalType": "bytes8[]", "name": "", "type": "bytes8[]" }, { "internalType": "bool[]", "name": "", "type": "bool[]" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" }, { "internalType": "address", "name": "", "type": "address" } ], "name": "getState", "outputs": [ { "internalType": "address", "name": "_provider", "type": "address" }, { "internalType": "bytes32", "name": "_initialHash", "type": "bytes32" }, { "internalType": "bytes32", "name": "_newHash", "type": "bytes32" }, { "internalType": "uint256", "name": "_numberSubmitted", "type": "uint256" }, { "internalType": "bytes32", "name": "_currentState", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "address", "name": "", "type": "address" } ], "name": "getSubInstances", "outputs": [ { "internalType": "address[]", "name": "", "type": "address[]" }, { "internalType": "uint256[]", "name": "", "type": "uint256[]" } ], "stateMutability": "pure", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "initialHash", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_owner", "type": "address" }, { "internalType": "address", "name": "_provider", "type": "address" }, { "internalType": "bytes32", "name": "_initialHash", "type": "bytes32" } ], "name": "instantiate", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "isActive", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" }, { "internalType": "address", "name": "_user", "type": "address" } ], "name": "isConcerned", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "newHash", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" }, { "internalType": "uint64", "name": "_position", "type": "uint64" }, { "internalType": "bytes8", "name": "_value", "type": "bytes8" }, { "internalType": "bytes32[]", "name": "proof", "type": "bytes32[]" } ], "name": "proveRead", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" }, { "internalType": "uint64", "name": "_position", "type": "uint64" }, { "internalType": "bytes8", "name": "_oldValue", "type": "bytes8" }, { "internalType": "bytes8", "name": "_newValue", "type": "bytes8" }, { "internalType": "bytes32[]", "name": "proof", "type": "bytes32[]" } ], "name": "proveWrite", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "provider", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "stateIsFinishedReplay", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "stateIsWaitingProofs", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_index", "type": "uint256" } ], "name": "stateIsWaitingReplay", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" } ], "transactionHash": "0x346b887b19c7bcc150ecb312176c1df29e0f0f6851a3ce6c7163fe507f98481f", "receipt": { "to": null, "from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0", "contractAddress": "0x7925A01C44eC8206F03435847503C65C6d1A5ab4", "transactionIndex": 2, "gasUsed": "1670027", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "blockHash": "0x6ff5e68ee28af72e24663133ce6a2169748428c44be3b120dae45bec63f6b737", "transactionHash": "0x346b887b19c7bcc150ecb312176c1df29e0f0f6851a3ce6c7163fe507f98481f", "logs": [], "blockNumber": 7117917, "cumulativeGasUsed": "2695714", "status": 1, "byzantium": true }, "args": [], "solcInputHash": "1f1c67ab264115ec013a38f727f2ffe8", "metadata": "{\"compiler\":{\"version\":\"0.7.4+commit.3f05b770\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"FinishedProofs\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"FinishedReplay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"}],\"name\":\"MemoryCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"_wasRead\",\"type\":\"bool\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_position\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"_value\",\"type\":\"bytes8\"}],\"name\":\"ValueProved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_position\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"_value\",\"type\":\"bytes8\"}],\"name\":\"ValueRead\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"_position\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"_value\",\"type\":\"bytes8\"}],\"name\":\"ValueWritten\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"currentIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"finishProofPhase\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"finishReplayPhase\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getCurrentState\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_roundDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timeToStartMachine\",\"type\":\"uint256\"}],\"name\":\"getCurrentStateDeadline\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_roundDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timeToStartMachine\",\"type\":\"uint256\"}],\"name\":\"getMaxInstanceDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentNonce\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getRWArrays\",\"outputs\":[{\"internalType\":\"uint64[]\",\"name\":\"\",\"type\":\"uint64[]\"},{\"internalType\":\"bytes8[]\",\"name\":\"\",\"type\":\"bytes8[]\"},{\"internalType\":\"bool[]\",\"name\":\"\",\"type\":\"bool[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getState\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_newHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"_numberSubmitted\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_currentState\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getSubInstances\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"initialHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"}],\"name\":\"instantiate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"isActive\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"isConcerned\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"newHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_position\",\"type\":\"uint64\"},{\"internalType\":\"bytes8\",\"name\":\"_value\",\"type\":\"bytes8\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"proveRead\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_position\",\"type\":\"uint64\"},{\"internalType\":\"bytes8\",\"name\":\"_oldValue\",\"type\":\"bytes8\"},{\"internalType\":\"bytes8\",\"name\":\"_newValue\",\"type\":\"bytes8\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"proveWrite\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"provider\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsFinishedReplay\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsWaitingProofs\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsWaitingReplay\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getMaxInstanceDuration(uint256,uint256)\":{\"params\":{\"_timeToStartMachine\":\"time to build the machine for the first time\"}},\"instantiate(address,address,bytes32)\":{\"params\":{\"_initialHash\":\"hash before divergence, in which both client and provider agree.\",\"_provider\":\"address that will provide memory values/proofs.\"},\"returns\":{\"_0\":\"MemoryManager index.\"}},\"proveWrite(uint256,uint64,bytes8,bytes8,bytes32[])\":{\"params\":{\"_newValue\":\"to be written\",\"_oldValue\":\"before write\",\"_position\":\"to be written\",\"proof\":\"The proof that the old value was correct\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"finishProofPhase(uint256)\":{\"notice\":\"Stop memory insertion and start read and write phase\"},\"finishReplayPhase(uint256)\":{\"notice\":\"Stop write (or read) phase\"},\"instantiate(address,address,bytes32)\":{\"notice\":\"Instantiate a memory manager instance.\"},\"proveRead(uint256,uint64,bytes8,bytes32[])\":{\"notice\":\"Proves that a certain value in current memory is correct\"},\"proveWrite(uint256,uint64,bytes8,bytes8,bytes32[])\":{\"notice\":\"Register a write operation and update newHash\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MMInstantiator.sol\":\"MMInstantiator\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@cartesi/util/contracts/Decorated.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\\npragma solidity ^0.7.0;\\n\\n\\ncontract Decorated {\\n // This contract defines several modifiers but does not use\\n // them - they will be used in derived contracts.\\n modifier onlyBy(address user) {\\n require(msg.sender == user, \\\"Cannot be called by user\\\");\\n _;\\n }\\n\\n modifier onlyAfter(uint256 time) {\\n require(block.timestamp > time, \\\"Cannot be called now\\\");\\n _;\\n }\\n}\\n\",\"keccak256\":\"0xdbba019b8f7f93b212a5bbae402ee988321c4fa82ed2b4c9e55b4d7ddf35dcc3\",\"license\":\"Apache-2.0\"},\"@cartesi/util/contracts/Instantiator.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\\npragma solidity ^0.7.0;\\n\\n\\ninterface Instantiator {\\n\\n modifier onlyInstantiated(uint256 _index) virtual;\\n\\n modifier onlyActive(uint256 _index) virtual;\\n\\n modifier increasesNonce(uint256 _index) virtual;\\n\\n function isActive(uint256 _index) external view returns (bool);\\n\\n function getNonce(uint256 _index) external view returns (uint256);\\n\\n function isConcerned(uint256 _index, address _user) external view returns (bool);\\n\\n function getSubInstances(uint256 _index, address) external view returns (address[] memory _addresses, uint256[] memory _indices);\\n}\\n\",\"keccak256\":\"0x416e612dc09b10765de32ec06cf0a7ee4e050e16db8bf3b8ad832a6082b7dfd6\",\"license\":\"Apache-2.0\"},\"@cartesi/util/contracts/InstantiatorImpl.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\\npragma solidity ^0.7.0;\\n\\nimport \\\"./Instantiator.sol\\\";\\n\\nabstract contract InstantiatorImpl is Instantiator {\\n uint256 public currentIndex = 0;\\n\\n mapping(uint256 => bool) internal active;\\n mapping(uint256 => uint256) internal nonce;\\n\\n modifier onlyInstantiated(uint256 _index) override {\\n require(currentIndex > _index, \\\"Index not instantiated\\\");\\n _;\\n }\\n\\n modifier onlyActive(uint256 _index) override {\\n require(currentIndex > _index, \\\"Index not instantiated\\\");\\n require(isActive(_index), \\\"Index inactive\\\");\\n _;\\n }\\n\\n modifier increasesNonce(uint256 _index) override {\\n nonce[_index]++;\\n _;\\n }\\n\\n function isActive(uint256 _index) public override view returns (bool) {\\n return (active[_index]);\\n }\\n\\n function getNonce(uint256 _index)\\n public\\n override\\n view\\n onlyActive(_index)\\n returns (uint256 currentNonce)\\n {\\n return nonce[_index];\\n }\\n\\n function deactivate(uint256 _index) internal {\\n active[_index] = false;\\n nonce[_index] = 0;\\n }\\n}\\n\",\"keccak256\":\"0x8f8e29b807e5c55198206a370b4d8751cbd98a663e3f89faff274e2f9d7cae75\",\"license\":\"Apache-2.0\"},\"@cartesi/util/contracts/Merkle.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\\n/// @title Library for Merkle proofs\\npragma solidity ^0.7.0;\\n\\n\\nlibrary Merkle {\\n function getPristineHash(uint8 _log2Size) public pure returns (bytes32) {\\n require(_log2Size >= 3, \\\"Has to be at least one word\\\");\\n require(_log2Size <= 64, \\\"Cannot be bigger than the machine itself\\\");\\n\\n bytes8 value = 0;\\n bytes32 runningHash = keccak256(abi.encodePacked(value));\\n\\n for (uint256 i = 3; i < _log2Size; i++) {\\n runningHash = keccak256(abi.encodePacked(runningHash, runningHash));\\n }\\n\\n return runningHash;\\n }\\n\\n function getRoot(uint64 _position, bytes8 _value, bytes32[] memory proof) public pure returns (bytes32) {\\n bytes32 runningHash = keccak256(abi.encodePacked(_value));\\n\\n return getRootWithDrive(\\n _position,\\n 3,\\n runningHash,\\n proof\\n );\\n }\\n\\n function getRootWithDrive(\\n uint64 _position,\\n uint8 _logOfSize,\\n bytes32 _drive,\\n bytes32[] memory siblings\\n ) public pure returns (bytes32)\\n {\\n require(_logOfSize >= 3, \\\"Must be at least a word\\\");\\n require(_logOfSize <= 64, \\\"Cannot be bigger than the machine itself\\\");\\n\\n uint64 size = uint64(2) ** _logOfSize;\\n\\n require(((size - 1) & _position) == 0, \\\"Position is not aligned\\\");\\n require(siblings.length == 64 - _logOfSize, \\\"Proof length does not match\\\");\\n\\n bytes32 drive = _drive;\\n\\n for (uint64 i = 0; i < siblings.length; i++) {\\n if ((_position & (size << i)) == 0) {\\n drive = keccak256(abi.encodePacked(drive, siblings[i]));\\n } else {\\n drive = keccak256(abi.encodePacked(siblings[i], drive));\\n }\\n }\\n\\n return drive;\\n }\\n\\n function getLog2Floor(uint256 number) public pure returns (uint8) {\\n\\n uint8 result = 0;\\n\\n uint256 checkNumber = number;\\n checkNumber = checkNumber >> 1;\\n while (checkNumber > 0) {\\n ++result;\\n checkNumber = checkNumber >> 1;\\n }\\n\\n return result;\\n }\\n\\n function isPowerOf2(uint256 number) public pure returns (bool) {\\n\\n uint256 checkNumber = number;\\n if (checkNumber == 0) {\\n return false;\\n }\\n\\n while ((checkNumber & 1) == 0) {\\n checkNumber = checkNumber >> 1;\\n }\\n\\n checkNumber = checkNumber >> 1;\\n\\n if (checkNumber == 0) {\\n return true;\\n }\\n\\n return false;\\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(isPowerOf2(hashes.length), \\\"The input array must contain power of 2 elements\\\");\\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 = 0; 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}\\n\",\"keccak256\":\"0xfab427885024176038f230531f5fbc87e80c38b22d7b5307a57a7a0b7cdfc6fe\",\"license\":\"Apache-2.0\"},\"contracts/MMInstantiator.sol\":{\"content\":\"// Copyright (C) 2020 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: GPL-3.0-only\\n// This program is free software: you can redistribute it and/or modify it under\\n// the terms of the GNU General Public License as published by the Free Software\\n// Foundation, either version 3 of the License, or (at your option) any later\\n// version.\\n\\n// This program is distributed in the hope that it will be useful, but WITHOUT ANY\\n// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\\n// PARTICULAR PURPOSE. See the GNU General Public License for more details.\\n\\n// You should have received a copy of the GNU General Public License\\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\\n\\n// Note: This component currently has dependencies that are licensed under the GNU\\n// GPL, version 3, and so you should treat this component as a whole as being under\\n// the GPL version 3. But all Cartesi-written code in this component is licensed\\n// under the Apache License, version 2, or a compatible permissive license, and can\\n// be used independently under the Apache v2 license. After this component is\\n// rewritten, the entire component will be released under the Apache v2 license.\\n\\n/// @title An instantiator of memory managers\\npragma solidity ^0.7.0;\\n\\nimport \\\"@cartesi/util/contracts/InstantiatorImpl.sol\\\";\\nimport \\\"@cartesi/util/contracts/Decorated.sol\\\";\\nimport \\\"./MMInterface.sol\\\";\\nimport \\\"@cartesi/util/contracts/Merkle.sol\\\";\\n\\ncontract MMInstantiator is InstantiatorImpl, MMInterface, Decorated {\\n // the provider will fill the memory for the client to read and write\\n // memory starts with hash and all values that are inserted are first verified\\n // then client can read inserted values and write some more\\n // finally the provider has to update the hash to account for writes\\n\\n struct ReadWrite {\\n bool wasRead;\\n uint64 position;\\n bytes8 value;\\n }\\n\\n // IMPLEMENT GARBAGE COLLECTOR AFTER AN INSTACE IS FINISHED!\\n struct MMCtx {\\n address owner;\\n address provider;\\n bytes32 initialHash;\\n bytes32 newHash; // hash after some write operations have been proved\\n ReadWrite[] history;\\n state currentState;\\n }\\n\\n mapping(uint256 => MMCtx) internal instance;\\n\\n // These are the possible states and transitions of the contract.\\n //\\n // +---+\\n // | |\\n // +---+\\n // |\\n // | instantiate\\n // v\\n // +---------------+ | proveRead\\n // | WaitingProofs |----| proveWrite\\n // +---------------+\\n // |\\n // | finishProofPhase\\n // v\\n // +----------------+ |read\\n // | WaitingReplay |----|write\\n // +----------------+\\n // |\\n // | finishReplayPhase\\n // v\\n // +----------------+\\n // | FinishedReplay |\\n // +----------------+\\n //\\n\\n event MemoryCreated(uint256 _index, bytes32 _initialHash);\\n event ValueProved(\\n uint256 _index,\\n bool _wasRead,\\n uint64 _position,\\n bytes8 _value\\n );\\n event ValueRead(uint256 _index, uint64 _position, bytes8 _value);\\n event ValueWritten(uint256 _index, uint64 _position, bytes8 _value);\\n event FinishedProofs(uint256 _index);\\n event FinishedReplay(uint256 _index);\\n\\n /// @notice Instantiate a memory manager instance.\\n /// @param _provider address that will provide memory values/proofs.\\n /// @param _initialHash hash before divergence, in which both client and provider agree.\\n /// @return MemoryManager index.\\n function instantiate(\\n address _owner,\\n address _provider,\\n bytes32 _initialHash\\n ) public override returns (uint256) {\\n MMCtx storage currentInstance = instance[currentIndex];\\n currentInstance.owner = _owner;\\n currentInstance.provider = _provider;\\n currentInstance.initialHash = _initialHash;\\n currentInstance.newHash = _initialHash;\\n currentInstance.currentState = state.WaitingProofs;\\n emit MemoryCreated(currentIndex, _initialHash);\\n\\n active[currentIndex] = true;\\n return currentIndex++;\\n }\\n\\n /// @notice Proves that a certain value in current memory is correct\\n // @param _position The address of the value to be confirmed\\n // @param _value The value in that address to be confirmed\\n // @param proof The proof that this value is correct\\n function proveRead(\\n uint256 _index,\\n uint64 _position,\\n bytes8 _value,\\n bytes32[] memory proof\\n )\\n public\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].provider)\\n increasesNonce(_index)\\n {\\n require(\\n instance[_index].currentState == state.WaitingProofs,\\n \\\"CurrentState is not WaitingProofs, cannot proveRead\\\"\\n );\\n require(\\n Merkle.getRoot(_position, _value, proof) ==\\n instance[_index].newHash,\\n \\\"Merkle proof does not match\\\"\\n );\\n instance[_index].history.push(ReadWrite(true, _position, _value));\\n emit ValueProved(_index, true, _position, _value);\\n }\\n\\n /// @notice Register a write operation and update newHash\\n /// @param _position to be written\\n /// @param _oldValue before write\\n /// @param _newValue to be written\\n /// @param proof The proof that the old value was correct\\n function proveWrite(\\n uint256 _index,\\n uint64 _position,\\n bytes8 _oldValue,\\n bytes8 _newValue,\\n bytes32[] memory proof\\n )\\n public\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].provider)\\n increasesNonce(_index)\\n {\\n require(\\n instance[_index].currentState == state.WaitingProofs,\\n \\\"CurrentState is not WaitingProofs, cannot proveWrite\\\"\\n );\\n // check proof of old value\\n require(\\n Merkle.getRoot(_position, _oldValue, proof) ==\\n instance[_index].newHash,\\n \\\"Merkle proof of write does not match\\\"\\n );\\n // update root\\n instance[_index].newHash = Merkle.getRoot(_position, _newValue, proof);\\n instance[_index].history.push(ReadWrite(false, _position, _newValue));\\n emit ValueProved(_index, false, _position, _newValue);\\n }\\n\\n /// @notice Stop memory insertion and start read and write phase\\n function finishProofPhase(uint256 _index)\\n public\\n override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].provider)\\n increasesNonce(_index)\\n {\\n require(\\n instance[_index].currentState == state.WaitingProofs,\\n \\\"CurrentState is not WaitingProofs, cannot finishProofPhase\\\"\\n );\\n instance[_index].currentState = state.WaitingReplay;\\n emit FinishedProofs(_index);\\n }\\n\\n /// @notice Stop write (or read) phase\\n function finishReplayPhase(uint256 _index)\\n public\\n override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].owner)\\n increasesNonce(_index)\\n {\\n require(stateIsWaitingReplay(_index), \\\"State of MM should be WaitingReplay\\\");\\n delete (instance[_index].history);\\n instance[_index].currentState = state.FinishedReplay;\\n\\n deactivate(_index);\\n emit FinishedReplay(_index);\\n }\\n\\n // getter methods\\n function getRWArrays(uint256 _index)\\n public\\n override\\n view\\n returns (\\n uint64[] memory,\\n bytes8[] memory,\\n bool[] memory\\n )\\n {\\n ReadWrite[] storage his = instance[_index].history;\\n uint256 length = his.length;\\n uint64[] memory positions = new uint64[](length);\\n bytes8[] memory values = new bytes8[](length);\\n bool[] memory isRead = new bool[](length);\\n\\n for (uint256 i = 0; i < length; i++) {\\n positions[i] = his[i].position;\\n values[i] = his[i].value;\\n isRead[i] = his[i].wasRead;\\n }\\n\\n return (positions, values, isRead);\\n }\\n\\n function isConcerned(uint256 _index, address _user)\\n public\\n override\\n view\\n returns (bool)\\n {\\n return instance[_index].provider == _user;\\n }\\n\\n function getState(uint256 _index, address)\\n public\\n view\\n onlyInstantiated(_index)\\n returns (\\n address _provider,\\n bytes32 _initialHash,\\n bytes32 _newHash,\\n uint256 _numberSubmitted,\\n bytes32 _currentState\\n )\\n {\\n MMCtx memory i = instance[_index];\\n\\n return (\\n i.provider,\\n i.initialHash,\\n i.newHash,\\n i.history.length,\\n getCurrentState(_index)\\n );\\n }\\n\\n function getSubInstances(uint256, address)\\n public\\n override\\n pure\\n returns (address[] memory, uint256[] memory)\\n {\\n address[] memory a = new address[](0);\\n uint256[] memory i = new uint256[](0);\\n return (a, i);\\n }\\n\\n function provider(uint256 _index)\\n public\\n view\\n onlyInstantiated(_index)\\n returns (address)\\n {\\n return instance[_index].provider;\\n }\\n\\n function initialHash(uint256 _index)\\n public\\n view\\n onlyInstantiated(_index)\\n returns (bytes32)\\n {\\n return instance[_index].initialHash;\\n }\\n\\n function newHash(uint256 _index)\\n public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (bytes32)\\n {\\n return instance[_index].newHash;\\n }\\n\\n // state getters\\n\\n function getCurrentState(uint256 _index)\\n public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (bytes32)\\n {\\n if (instance[_index].currentState == state.WaitingProofs) {\\n return \\\"WaitingProofs\\\";\\n }\\n if (instance[_index].currentState == state.WaitingReplay) {\\n return \\\"WaitingReplay\\\";\\n }\\n if (instance[_index].currentState == state.FinishedReplay) {\\n return \\\"FinishedReplay\\\";\\n }\\n require(false, \\\"Unrecognized state\\\");\\n }\\n\\n /// @notice Get the worst case scenario duration for a specific state\\n /// @param _roundDuration security parameter, the max time an agent\\n // has to react and submit one simple transaction\\n /// @param _timeToStartMachine time to build the machine for the first time\\n function getMaxStateDuration(\\n state _state,\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine\\n ) private pure returns (uint256) {\\n if (_state == state.WaitingProofs) {\\n // proving siblings is assumed to be free\\n // so its time to start the machine\\n // + one round duration to send the proofs\\n // + one transaction for finishProofPhase transaction\\n return _timeToStartMachine + uint256(2) * _roundDuration;\\n }\\n if (_state == state.WaitingReplay) {\\n // one transaction for the step function to be completed\\n return _roundDuration;\\n }\\n if (_state == state.FinishedReplay) {\\n // one transaction for finishReplay transaction\\n return _roundDuration;\\n }\\n\\n require(false, \\\"Unrecognized state\\\");\\n }\\n\\n function getCurrentStateDeadline(\\n uint256 _index,\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine\\n ) public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (uint256)\\n {\\n return getMaxStateDuration(\\n instance[_index].currentState,\\n _roundDuration,\\n _timeToStartMachine\\n );\\n }\\n\\n /// @notice Get the worst case scenario duration for an instance of this contract\\n /// @param _roundDuration security parameter, the max time an agent\\n // has to react and submit one simple transaction\\n /// @param _timeToStartMachine time to build the machine for the first time\\n function getMaxInstanceDuration(\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine\\n ) public override pure returns (uint256) {\\n uint256 waitingProofsDuration = getMaxStateDuration(\\n state.WaitingProofs,\\n _roundDuration,\\n _timeToStartMachine\\n );\\n\\n uint256 waitingReplayDuration = getMaxStateDuration(\\n state.WaitingReplay,\\n _roundDuration,\\n _timeToStartMachine\\n );\\n\\n uint256 finishProofsDuration = getMaxStateDuration(\\n state.WaitingProofs,\\n _roundDuration,\\n _timeToStartMachine\\n );\\n\\n return\\n waitingProofsDuration +\\n waitingReplayDuration +\\n finishProofsDuration;\\n }\\n\\n // remove these functions and change tests accordingly\\n function stateIsWaitingProofs(uint256 _index)\\n public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (bool)\\n {\\n return instance[_index].currentState == state.WaitingProofs;\\n }\\n\\n function stateIsWaitingReplay(uint256 _index)\\n public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (bool)\\n {\\n return instance[_index].currentState == state.WaitingReplay;\\n }\\n\\n function stateIsFinishedReplay(uint256 _index)\\n public\\n override\\n view\\n onlyInstantiated(_index)\\n returns (bool)\\n {\\n return instance[_index].currentState == state.FinishedReplay;\\n }\\n}\\n\",\"keccak256\":\"0x65547e53eae687057b4aff51233b3244e4608abdcc201e691947084ba07c240c\",\"license\":\"GPL-3.0-only\"},\"contracts/MMInterface.sol\":{\"content\":\"// Copyright (C) 2020 Cartesi Pte. Ltd.\\n\\n// SPDX-License-Identifier: GPL-3.0-only\\n// This program is free software: you can redistribute it and/or modify it under\\n// the terms of the GNU General Public License as published by the Free Software\\n// Foundation, either version 3 of the License, or (at your option) any later\\n// version.\\n\\n// This program is distributed in the hope that it will be useful, but WITHOUT ANY\\n// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\\n// PARTICULAR PURPOSE. See the GNU General Public License for more details.\\n\\n// You should have received a copy of the GNU General Public License\\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\\n\\n// Note: This component currently has dependencies that are licensed under the GNU\\n// GPL, version 3, and so you should treat this component as a whole as being under\\n// the GPL version 3. But all Cartesi-written code in this component is licensed\\n// under the Apache License, version 2, or a compatible permissive license, and can\\n// be used independently under the Apache v2 license. After this component is\\n// rewritten, the entire component will be released under the Apache v2 license.\\n\\n/// @title Interface for memory manager instantiator\\npragma solidity ^0.7.0;\\n\\nimport \\\"@cartesi/util/contracts/Instantiator.sol\\\";\\n\\ninterface MMInterface is Instantiator {\\n enum state {WaitingProofs, WaitingReplay, FinishedReplay}\\n\\n function getCurrentState(uint256 _index) external view returns (bytes32);\\n\\n function instantiate(\\n address _owner,\\n address _provider,\\n bytes32 _initialHash\\n ) external returns (uint256);\\n\\n function newHash(uint256 _index) external view returns (bytes32);\\n\\n function finishProofPhase(uint256 _index) external;\\n\\n function finishReplayPhase(uint256 _index) external;\\n\\n function getRWArrays(\\n uint256 _index\\n )\\n external\\n view\\n returns (\\n uint64[] memory,\\n bytes8[] memory,\\n bool[] memory\\n );\\n\\n function stateIsWaitingProofs(uint256 _index) external view returns (bool);\\n\\n function stateIsWaitingReplay(uint256 _index) external view returns (bool);\\n\\n function stateIsFinishedReplay(uint256 _index) extern