@cartesi/arbitration
Version:
Arbitration DLib
589 lines • 118 kB
JSON
{
"address": "0xc9129903751dA0855c7a7df7ab4b2b5e1DDd0C5c",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_partitionInstantiatorAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_mmInstantiatorAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "MemoryWriten",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "_mmInstance",
"type": "uint256"
}
],
"name": "PartitionDivergenceFound",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "_challenger",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "_claimer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "_roundDuration",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "_machineAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "_initialHash",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "_claimerFinalHash",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "_finalTime",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "_partitionInstance",
"type": "uint256"
}
],
"name": "VGCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "enum VGInterface.state",
"name": "_finalState",
"type": "uint8"
}
],
"name": "VGFinished",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "claimVictoryByTime",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "currentIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"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"
}
],
"name": "getCurrentStateDeadline",
"outputs": [
{
"internalType": "uint256",
"name": "time",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundDuration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_timeToStartMachine",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_partitionSize",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_maxCycle",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_picoSecondsToRunInsn",
"type": "uint256"
}
],
"name": "getMaxInstanceDuration",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"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": "getPartitionGameIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "getPartitionQuerySize",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "getState",
"outputs": [
{
"internalType": "address",
"name": "_challenger",
"type": "address"
},
{
"internalType": "address",
"name": "_claimer",
"type": "address"
},
{
"internalType": "contract MachineInterface",
"name": "_machine",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_initialHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_claimerFinalHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_hashBeforeDivergence",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_hashAfterDivergence",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_currentState",
"type": "bytes32"
},
{
"internalType": "uint256[]",
"name": "_uintValues",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "getSubInstances",
"outputs": [
{
"internalType": "address[]",
"name": "_addresses",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "_indices",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_challenger",
"type": "address"
},
{
"internalType": "address",
"name": "_claimer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_roundDuration",
"type": "uint256"
},
{
"internalType": "address",
"name": "_machineAddress",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_initialHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_claimerFinalHash",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "_finalTime",
"type": "uint256"
}
],
"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": "x",
"type": "uint256"
}
],
"name": "log2OverTwo",
"outputs": [
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "settleVerificationGame",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "startMachineRunChallenge",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsFinishedChallengerWon",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsFinishedClaimerWon",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "winByPartitionTimeout",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"transactionHash": "0xcd9f87b30aa2eb892139d409148958f2c93eacb0a9b31a979b5f9b7a961d2e30",
"receipt": {
"to": null,
"from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0",
"contractAddress": "0xc9129903751dA0855c7a7df7ab4b2b5e1DDd0C5c",
"transactionIndex": 0,
"gasUsed": "2462669",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x9be587a97f9a5c6cde7f3d2f672fd94d1c18637b6b2531c540552adbdc2ffc68",
"transactionHash": "0xcd9f87b30aa2eb892139d409148958f2c93eacb0a9b31a979b5f9b7a961d2e30",
"logs": [],
"blockNumber": 63234,
"cumulativeGasUsed": "2462669",
"status": 1,
"byzantium": true
},
"args": [
"0x0f4E152E9bc18De7043aB842B2445d8Cfa780336",
"0x31b3C8DF612a1255a54DEc11A0030820cF914b1B"
],
"solcInputHash": "1f1c67ab264115ec013a38f727f2ffe8",
"metadata": "{\"compiler\":{\"version\":\"0.7.4+commit.3f05b770\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_partitionInstantiatorAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_mmInstantiatorAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"MemoryWriten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_mmInstance\",\"type\":\"uint256\"}],\"name\":\"PartitionDivergenceFound\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_challenger\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_claimer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_roundDuration\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"_machineAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_claimerFinalHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_finalTime\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_partitionInstance\",\"type\":\"uint256\"}],\"name\":\"VGCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enum VGInterface.state\",\"name\":\"_finalState\",\"type\":\"uint8\"}],\"name\":\"VGFinished\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"claimVictoryByTime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"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\"}],\"name\":\"getCurrentStateDeadline\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_roundDuration\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timeToStartMachine\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_partitionSize\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxCycle\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_picoSecondsToRunInsn\",\"type\":\"uint256\"}],\"name\":\"getMaxInstanceDuration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"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\":\"getPartitionGameIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getPartitionQuerySize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getState\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_challenger\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_claimer\",\"type\":\"address\"},{\"internalType\":\"contract MachineInterface\",\"name\":\"_machine\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_claimerFinalHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_hashBeforeDivergence\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_hashAfterDivergence\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_currentState\",\"type\":\"bytes32\"},{\"internalType\":\"uint256[]\",\"name\":\"_uintValues\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getSubInstances\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_addresses\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_indices\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_challenger\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_claimer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_roundDuration\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_machineAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_claimerFinalHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"_finalTime\",\"type\":\"uint256\"}],\"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\":\"x\",\"type\":\"uint256\"}],\"name\":\"log2OverTwo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"settleVerificationGame\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"startMachineRunChallenge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsFinishedChallengerWon\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsFinishedClaimerWon\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"winByPartitionTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getMaxInstanceDuration(uint256,uint256,uint256,uint256,uint256)\":{\"params\":{\"_maxCycle\":\"is the maximum amount of steps a machine can perform\"}},\"instantiate(address,address,uint256,address,bytes32,bytes32,uint256)\":{\"params\":{\"_challenger\":\"address of the challenger.\",\"_claimer\":\"address of the claimer.\",\"_claimerFinalHash\":\"final hash claimed by claimer\",\"_finalTime\":\"max cycle of the machine for that computation\",\"_initialHash\":\"hash in which both claimer and challenger agree on\",\"_machineAddress\":\"address of the machine that will run the instruction\",\"_roundDuration\":\"duration of the round (security param)\"},\"returns\":{\"_0\":\"VG index.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"claimVictoryByTime(uint256)\":{\"notice\":\"Claimer can claim victory if challenger has lost the deadline for some of the steps in the protocol.\"},\"instantiate(address,address,uint256,address,bytes32,bytes32,uint256)\":{\"notice\":\"Instantiate a vg instance.\"},\"settleVerificationGame(uint256)\":{\"notice\":\"After having filled the memory manager with the necessary data, the provider calls this function to instantiate the machine and perform one step on it. The machine will write to memory now. Later, the provider will be expected to update the memory hash accordingly.\"},\"startMachineRunChallenge(uint256)\":{\"notice\":\"After the partition challenge has lead to a divergence in the hash within one time step, anyone can start a mechine run challenge to decide whether the claimer was correct about that particular step transition. This function call solely instantiate a memory manager, so the provider must fill the appropriate addresses that will be read by the machine.\"},\"winByPartitionTimeout(uint256)\":{\"notice\":\"In case one of the parties wins the partition challenge by timeout, then he or she can call this function to claim victory in the hireCPU contract as well.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/VGInstantiator.sol\":\"VGInstantiator\"},\"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\"},\"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) external view returns (bool);\\n\\n function getCurrentStateDeadline(\\n uint256 _index,\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine\\n ) external view returns (uint256);\\n\\n function getMaxInstanceDuration(\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine\\n ) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xc35a3addeda42b399d8995c1d3e8ea16746d1d95bb5214cd9709201bc9d702c0\",\"license\":\"GPL-3.0-only\"},\"contracts/MachineInterface.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\\n/// @title MachineInterface interface contract\\npragma solidity ^0.7.0;\\n\\n\\ninterface MachineInterface {\\n event StepGiven(uint8 exitCode);\\n\\n function step(\\n uint64[] memory _rwPositions,\\n bytes8[] memory _rwValues,\\n bool[] memory _isRead\\n ) external returns (uint8, uint256);\\n\\n function getMemoryInteractor() external view returns (address);\\n}\\n\",\"keccak256\":\"0x227a51ac54bc8246aec29d73bc48701c6c2bcd0ad0b606105c079f31283526d7\",\"license\":\"GPL-3.0-only\"},\"contracts/PartitionInterface.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 Abstract interface for partition instantiator\\npragma solidity ^0.7.0;\\n\\nimport \\\"@cartesi/util/contracts/Instantiator.sol\\\";\\n\\ninterface PartitionInterface is Instantiator {\\n enum state {\\n WaitingQuery,\\n WaitingHashes,\\n ChallengerWon,\\n ClaimerWon,\\n DivergenceFound\\n }\\n\\n function getCurrentState(uint256 _index) external view returns (bytes32);\\n\\n function instantiate(\\n address _challenger,\\n address _claimer,\\n bytes32 _initialHash,\\n bytes32 _claimerFinalHash,\\n uint256 _finalTime,\\n uint256 _querySize,\\n uint256 _roundDuration\\n ) external returns (uint256);\\n\\n function timeHash(uint256 _index, uint256 key)\\n external\\n view\\n returns (bytes32);\\n\\n function divergenceTime(uint256 _index) external view returns (uint256);\\n\\n function stateIsWaitingQuery(uint256 _index) external view returns (bool);\\n\\n function stateIsWaitingHashes(uint256 _index) external view returns (bool);\\n\\n function stateIsChallengerWon(uint256 _index) external view returns (bool);\\n\\n function stateIsClaimerWon(uint256 _index) external view returns (bool);\\n\\n function stateIsDivergenceFound(uint256 _index)\\n external\\n view\\n returns (bool);\\n\\n function getPartitionGameIndex(uint256 _index)\\n external\\n view\\n returns (uint256);\\n\\n function getQuerySize(uint256 _index) external view returns (uint256);\\n\\n function getCurrentStateDeadline(uint _index) external view returns (uint time);\\n\\n function getMaxInstanceDuration(\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine,\\n uint256 _partitionSize,\\n uint256 _maxCycle,\\n uint256 _picoSecondsToRunInsn\\n ) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xc8c1bf7c3ecd4b7a14be8bf70c93aad06873180056a63af9aca10a7f0e267bf8\",\"license\":\"GPL-3.0-only\"},\"contracts/VGInstantiator.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\\n// @title Verification game instantiator\\npragma solidity ^0.7.0;\\n\\nimport \\\"@cartesi/util/contracts/Decorated.sol\\\";\\nimport \\\"@cartesi/util/contracts/InstantiatorImpl.sol\\\";\\nimport \\\"./VGInterface.sol\\\";\\nimport \\\"./PartitionInterface.sol\\\";\\nimport \\\"./MMInterface.sol\\\";\\nimport \\\"./MachineInterface.sol\\\";\\n\\n\\ncontract VGInstantiator is InstantiatorImpl, Decorated, VGInterface {\\n // using SafeMath for uint;\\n\\n PartitionInterface private partition;\\n MMInterface private mm;\\n\\n struct VGCtx {\\n address challenger; // the two parties involved in each instance\\n address claimer;\\n uint roundDuration; // time interval to interact with this contract\\n MachineInterface machine; // the machine which will run the challenge\\n bytes32 initialHash; // hash of machine memory that both aggree uppon\\n bytes32 claimerFinalHash; // hash claimer commited for machine after running\\n uint finalTime; // the time for which the machine should run\\n uint timeOfLastMove; // last time someone made a move with deadline\\n uint256 mmInstance; // the instance of the memory that was given to this game\\n uint256 partitionInstance; // the partition instance given to this game\\n uint divergenceTime; // the time in which the divergence happened\\n bytes32 hashBeforeDivergence; // hash aggreed right before divergence\\n bytes32 hashAfterDivergence; // hash in conflict right after divergence\\n state currentState;\\n }\\n\\n mapping(uint256 => VGCtx) private instance;\\n\\n // These are the possible states and transitions of the contract.\\n //\\n // +---+\\n // | |\\n // +---+\\n // |\\n // | instantiate\\n // v\\n // +----------------+ winByPartitionTimeout\\n // +-----------| WaitPartition |------------------------+\\n // | +----------------+ |\\n // | | |\\n // | winByPartitionTimeout | startMachineRunChallenge |\\n // | v |\\n // | +-----------------------+ |\\n // | +---------| WaitMemoryProveValues |---------------+ |\\n // | | +-----------------------+ | |\\n // | | | |\\n // | |claimVictoryByDeadline settleVerificationGame | |\\n // v v v v\\n // +--------------------+ +-----------------------+\\n // | FinishedClaimerWon | | FinishedChallengerWon |\\n // +--------------------+ +-----------------------+\\n //\\n\\n event VGCreated(\\n uint256 _index,\\n address _challenger,\\n address _claimer,\\n uint _roundDuration,\\n address _machineAddress,\\n bytes32 _initialHash,\\n bytes32 _claimerFinalHash,\\n uint _finalTime,\\n uint256 _partitionInstance\\n );\\n event PartitionDivergenceFound(uint256 _index, uint256 _mmInstance);\\n event MemoryWriten(uint256 _index);\\n event VGFinished(state _finalState);\\n\\n constructor(address _partitionInstantiatorAddress,\\n address _mmInstantiatorAddress) {\\n partition = PartitionInterface(_partitionInstantiatorAddress);\\n mm = MMInterface(_mmInstantiatorAddress);\\n }\\n\\n /// @notice Instantiate a vg instance.\\n /// @param _challenger address of the challenger.\\n /// @param _claimer address of the claimer.\\n /// @param _roundDuration duration of the round (security param)\\n /// @param _machineAddress address of the machine that will run the instruction\\n /// @param _initialHash hash in which both claimer and challenger agree on\\n /// @param _claimerFinalHash final hash claimed by claimer\\n /// @param _finalTime max cycle of the machine for that computation\\n /// @return VG index.\\n function instantiate(\\n address _challenger,\\n address _claimer,\\n uint _roundDuration,\\n address _machineAddress,\\n bytes32 _initialHash,\\n bytes32 _claimerFinalHash,\\n uint _finalTime) public override returns (uint256)\\n {\\n require(_finalTime > 0, \\\"Final time must be greater than zero\\\");\\n instance[currentIndex].challenger = _challenger;\\n instance[currentIndex].claimer = _claimer;\\n instance[currentIndex].roundDuration = _roundDuration * log2OverTwo(_finalTime) + 4;\\n instance[currentIndex].machine = MachineInterface(_machineAddress);\\n instance[currentIndex].initialHash = _initialHash;\\n instance[currentIndex].claimerFinalHash = _claimerFinalHash;\\n instance[currentIndex].finalTime = _finalTime;\\n instance[currentIndex].timeOfLastMove = block.timestamp;\\n instance[currentIndex].partitionInstance = partition.instantiate(\\n _challenger,\\n _claimer,\\n _initialHash,\\n _claimerFinalHash,\\n _finalTime,\\n 10,\\n _roundDuration\\n );\\n instance[currentIndex].currentState = state.WaitPartition;\\n emit VGCreated(\\n currentIndex,\\n _challenger,\\n _claimer,\\n _roundDuration * log2OverTwo(_finalTime) + 4,\\n _machineAddress,\\n _initialHash,\\n _claimerFinalHash,\\n _finalTime,\\n instance[currentIndex].partitionInstance\\n );\\n\\n active[currentIndex] = true;\\n return(currentIndex++);\\n }\\n\\n /// @notice In case one of the parties wins the partition challenge by\\n /// timeout, then he or she can call this function to claim victory in\\n /// the hireCPU contract as well.\\n\\n // TO-DO: should this stop existing? We can make claimVictory by timeout generic\\n function winByPartitionTimeout(uint256 _index) public override\\n onlyInstantiated(_index)\\n {\\n require(instance[_index].currentState == state.WaitPartition, \\\"State should be WaitPartition\\\");\\n uint256 partitionIndex = instance[_index].partitionInstance;\\n if (partition.stateIsChallengerWon(partitionIndex)) {\\n challengerWins(_index);\\n return;\\n }\\n if (partition.stateIsClaimerWon(partitionIndex)) {\\n claimerWins(_index);\\n return;\\n }\\n revert(\\\"Fail to WinByPartitionTimeout in current condition\\\");\\n }\\n\\n /// @notice After the partition challenge has lead to a divergence in the hash\\n /// within one time step, anyone can start a mechine run challenge to decide\\n /// whether the claimer was correct about that particular step transition.\\n /// This function call solely instantiate a memory manager, so the\\n /// provider must fill the appropriate addresses that will be read by the\\n /// machine.\\n function startMachineRunChallenge(uint256 _index) public override\\n onlyInstantiated(_index)\\n increasesNonce(_index)\\n {\\n require(instance[_index].currentState == state.WaitPartition, \\\"State should be WaitPartition\\\");\\n require(partition.stateIsDivergenceFound(instance[_index].partitionInstance), \\\"Divergence should be found\\\");\\n uint256 partitionIndex = instance[_index].partitionInstance;\\n uint divergenceTime = partition.divergenceTime(partitionIndex);\\n instance[_index].divergenceTime = divergenceTime;\\n instance[_index].hashBeforeDivergence = partition.timeHash(partitionIndex, divergenceTime);\\n instance[_index].hashAfterDivergence = partition.timeHash(partitionIndex, divergenceTime + 1);\\n instance[_index].mmInstance = mm.instantiate(\\n address(this),\\n instance[_index].challenger,\\n instance[_index].hashBeforeDivergence\\n );\\n // !!!!!!!!! should call clear in partitionInstance !!!!!!!!!\\n delete instance[_index].partitionInstance;\\n instance[_index].timeOfLastMove = block.timestamp;\\n instance[_index].currentState = state.WaitMemoryProveValues;\\n emit PartitionDivergenceFound(_index, instance[_index].mmInstance);\\n }\\n\\n /// @notice After having filled the memory manager with the necessary data,\\n /// the provider calls this function to instantiate the machine and perform\\n /// one step on it. The machine will write to memory now. Later, the\\n /// provider will be expected to update the memory hash accordingly.\\n function settleVerificationGame(uint256 _index) public override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].challenger)\\n {\\n require(instance[_index].currentState == state.WaitMemoryProveValues, \\\"State should be WaitMemoryProveValues\\\");\\n uint256 mmIndex = instance[_index].mmInstance;\\n require(mm.stateIsWaitingReplay(mmIndex), \\\"State of MM should be WaitingReplay\\\");\\n\\n (\\n uint64[] memory positions,\\n bytes8[] memory values,\\n bool[] memory wasRead\\n ) = mm.getRWArrays(mmIndex);\\n\\n (uint8 exitCode, uint256 memoryAccesses) = instance[_index].machine.step(positions, values, wasRead);\\n\\n mm.finishReplayPhase(mmIndex);\\n\\n require(mm.stateIsFinishedReplay(mmIndex), \\\"State of MM should be FinishedReplay\\\");\\n \\n if( exitCode == 0 && // Step exits correctly\\n memoryAccesses == positions.length && // Number of memory acceses matches\\n mm.newHash(mmIndex) != instance[_index].hashAfterDivergence // proves challenger newHash diverge from claimer\\n ) {\\n challengerWins(_index);\\n }\\n claimerWins(_index);\\n }\\n\\n /// @notice Claimer can claim victory if challenger has lost the deadline\\n /// for some of the steps in the protocol.\\n function claimVictoryByTime(uint256 _index) public override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].claimer)\\n {\\n // TO-DO: should we add onlyAfter as a function in solidity-utils lib?\\n // This should be the onlyAfter modifier, but it cannot use functions:\\n // DeclarationError: Function type can not be used in this context.\\n // TO-DO: change the hardcode numbers\\n require(\\n block.timestamp > instance[_index].timeOfLastMove + getMaxStateDuration(\\n instance[_index].currentState,\\n instance[_index].roundDuration,\\n 40, // time to start machine\\n partition.getQuerySize(instance[_index].partitionInstance),\\n instance[_index].finalTime, //maxCycle\\n 500 // pico seconds to run insn\\n ), \\\"Duration of WaitMemoryProveValues must be over\\\");\\n\\n require(instance[_index].currentState == state.WaitMemoryProveValues, \\\"State should be WaitMemoryProveValues\\\");\\n claimerWins(_index);\\n }\\n\\n // state getters\\n function getCurrentStateDeadline(uint _index) public view\\n onlyInstantiated(_index)\\n returns (uint time)\\n {\\n VGCtx memory i = instance[_index];\\n time = i.timeOfLastMove + getMaxStateDuration(\\n _index,\\n i.roundDuration,\\n 40 // time to start machine @DEV I want to use preprocessor constant for this, like:\\n // #def TIM