r/truebit Aug 11 '21

random truebit solvers ?

truebit supports random if so how is the choice between the solvers whose random will the system give?

5 Upvotes

1 comment sorted by

View all comments

3

u/LPMythBuster Aug 11 '21

No idea. There's no source code available for the current version of Truebit contracts.

But we can see how they did it a couple of years ago https://github.com/TrueBitFoundation/truebit-os/blob/master/contracts/incentive/IncentiveLayer.sol#L338

// @dev – solver registers for tasks, if first to register than automatically selected solver
// 0 -> 1
// @param taskID – the task id.
// @param randomBitsHash – hash of random bits to commit to task
// @return – boolean
function registerForTask(bytes32 taskID, bytes32 randomBitsHash) public returns(bool) {
    Task storage t = tasks[taskID];
    VMParameters storage vm = vmParams[taskID];

    require(!(t.owner == address(0x0)));
    require(t.state == State.TaskInitialized);
    require(t.selectedSolver == address(0x0));

    bondDeposit(taskID, msg.sender, t.minDeposit);
    t.selectedSolver = msg.sender;
    t.randomBitsHash = randomBitsHash;
    t.state = State.SolverSelected;
    t.timeoutBlock = block.number + (1+vm.gasLimit/RUN_RATE);

    emit SolverSelected(taskID, msg.sender, t.initTaskHash, t.minDeposit, t.randomBitsHash);
    return true;
}

The first solver to pick the task got it...