@cartesi/arbitration
Version:
Arbitration DLib
617 lines • 105 kB
JSON
{
"address": "0xDf9d3b1A08062E18E19704e5303C25DF52f7Ca8a",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_vgInstantiatorAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "ChallengeStarted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "_claimedFinalHash",
"type": "bytes32"
}
],
"name": "ClaimSubmitted",
"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": "uint256",
"name": "_finalTime",
"type": "uint256"
}
],
"name": "ComputeCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint8",
"name": "_state",
"type": "uint8"
}
],
"name": "ComputeFinished",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "ResultConfirmed",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "challenge",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "claimVictoryByTime",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "confirm",
"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": "_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"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "getState",
"outputs": [
{
"internalType": "address",
"name": "_challenger",
"type": "address"
},
{
"internalType": "address",
"name": "_claimer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_deadline",
"type": "uint256"
},
{
"internalType": "address",
"name": "_machine",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_initialHash",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "_finalTime",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "_claimedFinalHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_currentState",
"type": "bytes32"
}
],
"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": "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": "_index",
"type": "uint256"
}
],
"name": "stateIsChallengerWon",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsClaimerMissedDeadline",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsClaimerWon",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsConsensusResult",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsWaitingChallange",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsWaitingClaim",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "stateIsWaitingConfirmation",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "_claimedFinalHash",
"type": "bytes32"
}
],
"name": "submitClaim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
}
],
"name": "winByVG",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"transactionHash": "0x9933923bebb3847723c91b217aa4a964e3d5aaf74c6088f05be805dfd19c6113",
"receipt": {
"to": null,
"from": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0",
"contractAddress": "0xDf9d3b1A08062E18E19704e5303C25DF52f7Ca8a",
"transactionIndex": 4,
"gasUsed": "1816338",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x38122108a42484134c857b7ed48abd7d4f85c258585f66af7b669d6a44b288ab",
"transactionHash": "0x9933923bebb3847723c91b217aa4a964e3d5aaf74c6088f05be805dfd19c6113",
"logs": [],
"blockNumber": 4446984,
"cumulativeGasUsed": "2076512",
"status": 1,
"byzantium": true
},
"args": [
"0x52aEB4F988E9099b4ad22CB7253Ec222deA7Af98"
],
"solcInputHash": "1f1c67ab264115ec013a38f727f2ffe8",
"metadata": "{\"compiler\":{\"version\":\"0.7.4+commit.3f05b770\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_vgInstantiatorAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"ChallengeStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"_claimedFinalHash\",\"type\":\"bytes32\"}],\"name\":\"ClaimSubmitted\",\"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\":\"uint256\",\"name\":\"_finalTime\",\"type\":\"uint256\"}],\"name\":\"ComputeCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"_state\",\"type\":\"uint8\"}],\"name\":\"ComputeFinished\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"ResultConfirmed\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"challenge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"claimVictoryByTime\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"confirm\",\"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\":\"_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\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"getState\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"_challenger\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_claimer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_deadline\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_machine\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"_initialHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"_finalTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_claimedFinalHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_currentState\",\"type\":\"bytes32\"}],\"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\":\"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\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsChallengerWon\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsClaimerMissedDeadline\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsClaimerWon\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsConsensusResult\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsWaitingChallange\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsWaitingClaim\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"stateIsWaitingConfirmation\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"_claimedFinalHash\",\"type\":\"bytes32\"}],\"name\":\"submitClaim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"winByVG\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"challenge(uint256)\":{\"params\":{\"_index\":\"Index of compute instance which challenger is starting the VG.\"}},\"confirm(uint256)\":{\"params\":{\"_index\":\"Index of compute instance that the challenger is confirming the claim.\"}},\"getMaxInstanceDuration(uint256,uint256,uint256,uint256,uint256)\":{\"params\":{\"_maxCycle\":\"number of instructions until the machine is forcibly halted\",\"_picoSecondsToRunInsn\":\"time the offchain will take to run one instruction\"}},\"instantiate(address,address,uint256,address,bytes32,uint256)\":{\"params\":{\"_challenger\":\"address of the challenger.\",\"_claimer\":\"address of the 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\":\"Compute index.\"}},\"submitClaim(uint256,bytes32)\":{\"params\":{\"_claimedFinalHash\":\"hash of the machine after computation is completed.\",\"_index\":\"Index of instance that the claimer is interacting with\"}},\"winByVG(uint256)\":{\"params\":{\"_index\":\"Index of compute instance which challenger is starting the VG.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"challenge(uint256)\":{\"notice\":\"Challenger disputes the claim, starting a verification game.\"},\"claimVictoryByTime(uint256)\":{\"notice\":\"Claim victory for opponent timeout.\"},\"confirm(uint256)\":{\"notice\":\"Challenger accepts claim.\"},\"instantiate(address,address,uint256,address,bytes32,uint256)\":{\"notice\":\"Instantiates a compute instance.\"},\"submitClaim(uint256,bytes32)\":{\"notice\":\"Claimer claims the hash of the result of a computation\"},\"winByVG(uint256)\":{\"notice\":\"In case one of the parties wins the verification game, then he or she can call this function to claim victory in this contract as well.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/ComputeInstantiator.sol\":\"ComputeInstantiator\"},\"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/ComputeInstantiator.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 An instantiator of compute\\npragma solidity ^0.7.0;\\n\\nimport \\\"@cartesi/util/contracts/InstantiatorImpl.sol\\\";\\nimport \\\"@cartesi/util/contracts/Decorated.sol\\\";\\nimport \\\"./ComputeInterface.sol\\\";\\nimport \\\"./VGInterface.sol\\\";\\n\\n\\ncontract ComputeInstantiator is InstantiatorImpl, ComputeInterface, Decorated {\\n // after instantiation, the claimer will submit the final hash\\n // then the challenger can either accept of challenge.\\n // in the latter case a verification game will be instantiated\\n // to resolve the dispute.\\n\\n VGInterface private vg;\\n\\n // IMPLEMENT GARBAGE COLLECTOR AFTER AN INSTACE IS FINISHED!\\n struct ComputeCtx {\\n address challenger;\\n address claimer;\\n uint256 roundDuration; // time interval to interact with this contract\\n uint256 timeOfLastMove; // last time someone made a move with deadline\\n address machine; // machine which will run the challenge\\n bytes32 initialHash;\\n uint256 finalTime;\\n bytes32 claimedFinalHash;\\n uint256 vgInstance; // instance of verification game in case of dispute\\n state currentState;\\n }\\n\\n mapping(uint256 => ComputeCtx) internal instance;\\n\\n // These are the possible states and transitions of the contract.\\n\\n // +---+\\n // | |\\n // +---+\\n // |\\n // | instantiate\\n // v\\n // +--------------+ claimVictoryByTime +-----------------------+\\n // | WaitingClaim |------------------->| ClaimerMisseddeadline |\\n // +--------------+ +-----------------------+\\n // |\\n // | submitClaim\\n // v\\n // +---------------------+ confirm +-----------------+\\n // | WaitingConfirmation |------------>| ConsensusResult |\\n // +---------------------+ or deadline +-----------------+\\n // |\\n // | challenge\\n // v\\n // +------------------+ winByVG +---------------+\\n // | WaitingChallenge |--------------->| ChallengerWon |\\n // +------------------+ +---------------+\\n // |\\n // |\\n // | winByVG +------------+\\n // +-------------------------------->| ClaimerWon |\\n // +------------+\\n //\\n\\n event ComputeCreated(\\n uint256 _index,\\n address _challenger,\\n address _claimer,\\n uint256 _roundDuration,\\n address _machineAddress,\\n bytes32 _initialHash,\\n uint256 _finalTime\\n );\\n event ClaimSubmitted(uint256 _index, bytes32 _claimedFinalHash);\\n event ResultConfirmed(uint256 _index);\\n event ChallengeStarted(uint256 _index);\\n event ComputeFinished(uint256 _index, uint8 _state);\\n\\n constructor(address _vgInstantiatorAddress) {\\n vg = VGInterface(_vgInstantiatorAddress);\\n }\\n\\n /// @notice Instantiates a compute 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 _finalTime max cycle of the machine for that computation\\n /// @return Compute index.\\n function instantiate(\\n address _challenger,\\n address _claimer,\\n uint256 _roundDuration,\\n address _machineAddress,\\n bytes32 _initialHash,\\n uint256 _finalTime) public override returns (uint256)\\n {\\n require(_challenger != _claimer, \\\"Challenger and Claimer need to differ\\\");\\n ComputeCtx storage currentInstance = instance[currentIndex];\\n currentInstance.challenger = _challenger;\\n currentInstance.claimer = _claimer;\\n currentInstance.roundDuration = _roundDuration;\\n currentInstance.machine = _machineAddress;\\n currentInstance.initialHash = _initialHash;\\n currentInstance.finalTime = _finalTime;\\n currentInstance.currentState = state.WaitingClaim;\\n currentInstance.timeOfLastMove = block.timestamp;\\n\\n emit ComputeCreated(\\n currentIndex,\\n _challenger,\\n _claimer,\\n _roundDuration,\\n _machineAddress,\\n _initialHash,\\n _finalTime);\\n\\n active[currentIndex] = true;\\n return currentIndex++;\\n }\\n\\n /// @notice Claimer claims the hash of the result of a computation\\n /// @param _index Index of instance that the claimer is interacting with\\n /// @param _claimedFinalHash hash of the machine after computation is completed.\\n function submitClaim(uint256 _index, bytes32 _claimedFinalHash) public override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].claimer)\\n increasesNonce(_index)\\n {\\n require(instance[_index].currentState == state.WaitingClaim, \\\"State should be WaitingClaim\\\");\\n instance[_index].claimedFinalHash = _claimedFinalHash;\\n instance[_index].currentState = state.WaitingConfirmation;\\n\\n emit ClaimSubmitted(_index, _claimedFinalHash);\\n }\\n\\n /// @notice Challenger accepts claim.\\n /// @param _index Index of compute instance that the challenger is confirming the claim.\\n function confirm(uint256 _index) public override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].challenger)\\n increasesNonce(_index)\\n {\\n require(instance[_index].currentState == state.WaitingConfirmation, \\\"State should be WaitingConfirmation\\\");\\n instance[_index].currentState = state.ConsensusResult;\\n clearInstance(_index);\\n emit ResultConfirmed(_index);\\n }\\n\\n /// @notice Challenger disputes the claim, starting a verification game.\\n /// @param _index Index of compute instance which challenger is starting the VG.\\n function challenge(uint256 _index) public override\\n onlyInstantiated(_index)\\n onlyBy(instance[_index].challenger)\\n increasesNonce(_index)\\n {\\n require(instance[_index].currentState == state.WaitingConfirmation, \\\"State should be WaitingConfirmation\\\");\\n instance[_index].vgInstance = vg.instantiate(\\n instance[_index].challenger,\\n instance[_index].claimer,\\n instance[_index].roundDuration,\\n instance[_index].machine,\\n instance[_index].initialHash,\\n instance[_index].claimedFinalHash,\\n instance[_index].finalTime);\\n instance[_index].currentState = state.WaitingChallenge;\\n\\n emit ChallengeStarted(_index);\\n }\\n\\n /// @notice In case one of the parties wins the verification game,\\n /// then he or she can call this function to claim victory in\\n /// this contract as well.\\n /// @param _index Index of compute instance which challenger is starting the VG.\\n function winByVG(uint256 _index) public override\\n onlyInstantiated(_index)\\n increasesNonce(_index)\\n {\\n require(instance[_index].currentState == state.WaitingChallenge, \\\"State is not WaitingChallenge, cannot winByVG\\\");\\n uint256 vgIndex = instance[_index].vgInstance;\\n\\n if (vg.stateIsFinishedChallengerWon(vgIndex)) {\\n challengerWins(_index);\\n return;\\n }\\n\\n if (vg.stateIsFinishedClaimerWon(vgIndex)) {\\n claimerWins(_index);\\n return;\\n }\\n require(false, \\\"State of VG is not final\\\");\\n }\\n\\n /// @notice Claim victory for opponent timeout.\\n function claimVictoryByTime(uint256 _index) public override\\n onlyInstantiated(_index)\\n increasesNonce(_index)\\n {\\n bool afterDeadline = (block.timestamp > instance[_index].timeOfLastMove + getMaxStateDuration(\\n instance[_index].currentState,\\n instance[_index].roundDuration,\\n 40, // time to start machine\\n 1, // vg is not instantiated, so it doesnt matter\\n instance[_index].finalTime,\\n 500) // pico seconds to run instruction\\n );\\n\\n\\n require(afterDeadline, \\\"Deadline is not over for this specific state\\\");\\n\\n if ((msg.sender == instance[_index].challenger) && (instance[_index].currentState == state.WaitingClaim)) {\\n instance[_index].currentState = state.ClaimerMissedDeadline;\\n deactivate(_index);\\n emit ComputeFinished(_index, uint8(instance[_index].currentState));\\n return;\\n }\\n\\n if ((msg.sender == instance[_index].claimer) && (instance[_index].currentState == state.WaitingConfirmation)) {\\n instance[_index].currentState = state.ConsensusResult;\\n deactivate(_index);\\n emit ComputeFinished(_index, uint8(instance[_index].currentState));\\n return;\\n }\\n revert(\\\"Fail to ClaimVictoryByTime in current condition\\\");\\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 /// @param _partitionSize size of partition, how many instructions the\\n // will run to reach the necessary hash\\n /// @param _maxCycle is the maximum amount of steps a machine can perform\\n // before being forced into becoming halted\\n /// @param _picoSecondsToRunInsn time the offchain will take to run one instruction\\n function getMaxStateDuration(\\n state _state,\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine,\\n uint256 _partitionSize,\\n uint256 _maxCycle,\\n uint256 _picoSecondsToRunInsn\\n ) private view returns (uint256)\\n {\\n if (_state == state.WaitingClaim) {\\n // time to run entire machine + time to react\\n return _timeToStartMachine + ((_maxCycle * _picoSecondsToRunInsn) / 1e12) + _roundDuration;\\n }\\n\\n if (_state == state.WaitingConfirmation) {\\n // time to run entire machine + time to react\\n return _timeToStartMachine + ((_maxCycle * _picoSecondsToRunInsn) / 1e12) + _roundDuration;\\n }\\n\\n if (_state == state.WaitingChallenge) {\\n // time to run a verification game + time to react\\n return vg.getMaxInstanceDuration(_roundDuration, _timeToStartMachine, _partitionSize, _maxCycle, _picoSecondsToRunInsn) + _roundDuration;\\n }\\n\\n if (_state == state.ClaimerWon || _state == state.ChallengerWon || _state == state.ClaimerMissedDeadline || _state == state.ConsensusResult) {\\n return 0; // final state\\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 /// @param _partitionSize size of partition, how many instructions the\\n // will run to reach the necessary hash\\n /// @param _maxCycle number of instructions until the machine is forcibly halted\\n /// @param _picoSecondsToRunInsn time the offchain will take to run one instruction\\n function getMaxInstanceDuration(\\n uint256 _roundDuration,\\n uint256 _timeToStartMachine,\\n uint256 _partitionSize,\\n uint256 _maxCycle,\\n uint256 _picoSecondsToRunInsn\\n ) public view returns (uint256)\\n {\\n uint256 waitingClaim = getMaxStateDuration(\\n state.WaitingClaim,\\n _roundDuration,\\n _timeToStartMachine,\\n _partitionSize,\\n _maxCycle,\\n _picoSecondsToRunInsn\\n );\\n\\n uint256 waitingConfirmation = getMaxStateDuration(\\n state.WaitingConfirmation,\\n _roundDuration,\\n _timeToStartMachine,\\n _partitionSize,\\n _maxCycle,\\n _picoSecondsToRunInsn\\n );\\n\\n uint256 waitingChallenge = getMaxStateDuration(\\n state.WaitingChallenge,\\n _roundDuration,\\n _timeToStartMachine,\\n _partitionSize,\\n _maxCycle,\\n _picoSecondsToRunInsn\\n );\\n\\n return waitingClaim + waitingConfirmation + waitingChallenge;\\n }\\n\\n function isConcerned(uint256 _index, address _user) public override view returns (bool) {\\n return ((instance[_index].challenger == _user) || (instance[_index].claimer == _user));\\n }\\n\\n function getSubInstances(uint256 _index, address)\\n public override view returns (address[] memory _addresses,\\n uint256[] memory _indices)\\n {\\n address[] memory a;\\n uint256[] memory i;\\n if (instance[_index].currentState == state.WaitingChallenge) {\\n a = new address[](1);\\n i = new uint256[](1);\\n a[0] = address(vg);\\n i[0] = instance[_index].vgInstance;\\n return (a, i);\\n }\\n a = new address[](0);\\n i = new uint256[](0);\\n return (a, i);\\n }\\n\\n function getState(uint256 _index, address) public view returns\\n ( address _challenger,\\n address _claimer,\\n uint256 _deadline,\\n address _machine,\\n bytes32 _initialHash,\\n uint256 _finalTime,\\n bytes32 _claimedFinalHash,\\n bytes32 _currentState\\n )\\n {\\n ComputeCtx memory i = instance[_index];\\n\\n // we have to duplicate the code for getCurrentState because of\\n // \\\"stack too deep\\\"\\n\\n // this variables only matter on challenging state\\n uint256 partitionSize = 1;\\n uint256 partitionGameIndex = 1;\\n\\n bytes32 currentState;\\n if (i.currentState == state.WaitingClaim) {\\n currentState = \\\"WaitingClaim\\\";\\n }\\n if (i.currentState == state.WaitingConfirmation) {\\n currentState = \\\"WaitingConfirmation\\\";\\n }\\n if (i.currentState == state.ClaimerMissedDeadline) {\\n currentState = \\\"ClaimerMissedDeadline\\\";\\n }\\n if (i.currentState == state.WaitingChallenge) {\\n currentState = \\\"WaitingChallenge\\\";\\n partitionSize = vg.getPartitionQuerySize(i.vgInstance);\\n partitionGameIndex = vg.getPartitionGameIndex(i.vgInstance);\\n }\\n if (i.currentState == state.ChallengerWon) {\\n currentState = \\\"ChallengerWon\\\";\\n }\\n if (i.currentState == state.ClaimerWon) {\\n currentState = \\\"ClaimerWon\\\";\\n }\\n if (i.currentState == state.ConsensusResult) {\\n currentState = \\\"ConsensusResult\\\";\\n }\\n\\n return (\\n i.challenger,\\n i.claimer,\\n i.timeOfLastMove + getMaxStateDuration(\\n i.currentState,\\n i.roundDuration,\\n 40, // time to start machine\\n partitionSize,\\n i.finalTime,\\n 500 // pico seconds to run insn\\n ),\\n i.machine,\\n i.initialHash,\\n i.finalTime,\\n i.claimedFinalHash,\\n currentState\\n );\\n }\\n\\n function getCurrentState(uint256 _index) public override view\\n onlyInstantiated(_index)\\n returns (bytes32)\\n {\\n if (instance[_index].currentState == state.WaitingClaim) {\\n return \\\"WaitingClaim\\\";\\n }\\n if (instance[_index].currentState == state.WaitingConfirmation) {\\n return \\\"WaitingConfirmation\\\";\\n }\\n if (instance[_index].currentState == state.ClaimerMissedDeadline) {\\n return \\\"ClaimerMissedDeadline\\\";\\n }\\n if (instance[_index].currentState == state.WaitingChallenge) {\\n return \\\"WaitingChallenge\\\";\\n }\\n if (instance[_index].currentState == state.ChallengerWon) {\\n return \\\"ChallengerWon\\\";\\n }\\n if (instance[_index].currentState == state.ClaimerWon) {\\n return \\\"ClaimerWon\\\";\\n }\\n if (instance[_index].currentState == state.ConsensusResult) {\\n return \\\"ConsensusResult\\\";\\n }\\n require(false, \\\"Unrecognized state\\\");\\n }\\n\\n // remove these functions and change tests accordingly\\n function stateIsWaitingClaim(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.WaitingClaim; }\\n\\n function stateIsWaitingConfirmation(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.WaitingConfirmation; }\\n\\n function stateIsClaimerMissedDeadline(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.ClaimerMissedDeadline; }\\n\\n function stateIsWaitingChallange(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.WaitingChallenge; }\\n\\n function stateIsChallengerWon(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.ChallengerWon; }\\n\\n function stateIsClaimerWon(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.ClaimerWon; }\\n\\n function stateIsConsensusResult(uint256 _index) public view\\n onlyInstantiated(_index)\\n returns (bool)\\n { return instance[_index].currentState == state.ConsensusResult; }\\n\\n function clearInstance(uint256 _index) internal {\\n delete instance[_index].challenger;\\n delete instance[_index].claimer;\\n delete instance[_index].roundDuration;\\n delete instance[_index].timeOfLastMove;\\n delete instance[_index].machine;\\n delete instance[_index].initialHash;\\n delete instance[_index].finalTime;\\n // !!!!!!!!! should call clear in vgInstance !!!!!!!!!\\n delete instance[_index].vgInstance;\\n deactivate(_index);\\n }\\n\\n function challengerWins(uint256 _index) private\\n onlyInstantiated(_index)\\n {\\n clearInstance(_index);\\n instance[_index].currentState = state.ChallengerWon;\\n e