Skip to main content

PRT Core Contracts

Tournament Base Contract


joinTournament()

function joinTournament(Tree.Node finalState, bytes32[] calldata proof, Tree.Node leftChild, Tree.Node rightChild) external tournamentOpen tournamentNotFinished

Join a tournament by submitting a final computation hash with Merkle proof. Creates a match if another participant is waiting.

Event Emitted: commitmentJoined(Tree.Node root) when commitment is successfully added

Parameters:

NameTypeDescription
finalStateTree.NodeFinal computational hash
proofbytes32[]Merkle proof for the final state
leftChildTree.NodeLeft child of the commitment node
rightChildTree.NodeRight child of the commitment node

advanceMatch()

function advanceMatch(Match.Id calldata matchId, Tree.Node leftNode, Tree.Node rightNode, Tree.Node newLeftNode, Tree.Node newRightNode) external tournamentNotFinished

Advance a match by providing new intermediate nodes in the binary search process.

Parameters:

NameTypeDescription
matchIdMatch.IdIdentifier of the match to advance
leftNodeTree.NodeCurrent left node in the match
rightNodeTree.NodeCurrent right node in the match
newLeftNodeTree.NodeNew left node for next iteration
newRightNodeTree.NodeNew right node for next iteration

winMatchByTimeout()

function winMatchByTimeout(Match.Id calldata matchId) external tournamentNotFinished

Win a match when the opponent has run out of time allowance.

Parameters:

NameTypeDescription
matchIdMatch.IdIdentifier of the match to win by timeout

eliminateMatchByTimeout()

function eliminateMatchByTimeout(Match.Id calldata matchId) external tournamentNotFinished

Eliminate a match when both participants have run out of time.

Parameters:

NameTypeDescription
matchIdMatch.IdIdentifier of the match to eliminate

isFinished()

function isFinished() public view returns (bool)

Check if the tournament has finished (has a winner or is eliminated).

Returns:

NameTypeDescription
finishedboolWhether the tournament is finished

isClosed()

function isClosed() public view returns (bool)

Check if the tournament is closed to new participants.

Returns:

NameTypeDescription
closedboolWhether the tournament is closed

NonLeafTournament Contract Functions


sealInnerMatchAndCreateInnerTournament()

function sealInnerMatchAndCreateInnerTournament(Match.Id calldata matchId, Tree.Node leftLeaf, Tree.Node rightLeaf, Machine.Hash agreeHash, bytes32[] calldata agreeHashProof) external tournamentNotFinished

Seal an inner match and create a new inner tournament to resolve the dispute at a finer granularity.

Event Emitted: newInnerTournament(Match.IdHash indexed, NonRootTournament) when inner tournament is created

Parameters:

NameTypeDescription
matchIdMatch.IdIdentifier of the match to seal
leftLeafTree.NodeLeft leaf node of the disagreement
rightLeafTree.NodeRight leaf node of the disagreement
agreeHashMachine.HashAgreed upon machine state hash
agreeHashProofbytes32[]Merkle proof for the agreed hash

winInnerTournament()

function winInnerTournament(NonRootTournament innerTournament) external tournamentNotFinished

Process the result of a finished inner tournament and advance the parent match.

Parameters:

NameTypeDescription
innerTournamentNonRootTournamentAddress of the finished inner tournament

eliminateInnerTournament()

function eliminateInnerTournament(NonRootTournament innerTournament) external tournamentNotFinished

Eliminate an inner tournament that has no winner and advance the parent match.

Parameters:

NameTypeDescription
innerTournamentNonRootTournamentAddress of the inner tournament to eliminate

NonRootTournament Contract Functions


innerTournamentWinner()

function innerTournamentWinner() external view returns (bool, Tree.Node, Tree.Node, Clock.State memory)

Get the winner information from a finished inner tournament for parent tournament processing.

Returns:

NameTypeDescription
isFinishedboolWhether the tournament is finished
contestedCommitmentTree.NodeThe contested parent commitment
winnerCommitmentTree.NodeThe winning inner commitment
clockClock.StatePaused clock state of the winner

canBeEliminated()

function canBeEliminated() public view returns (bool)

Check if the tournament can be safely eliminated by its parent.

Returns:

NameTypeDescription
eliminatableboolWhether the tournament can be eliminated

RootTournament Contract Functions


arbitrationResult()

function arbitrationResult() external view returns (bool isFinished, Tree.Node winnerCommitment, Machine.Hash finalMachineStateHash)

Get the final arbitration result from the root tournament.

Returns:

NameTypeDescription
isFinishedboolWhether the tournament is finished
winnerCommitmentTree.NodeThe winning commitment
finalMachineStateHashMachine.HashFinal machine state hash of winner

Tournament Factory Functions


instantiate() (SingleLevelTournamentFactory)

function instantiate(Machine.Hash initialHash, IDataProvider provider) external returns (ITournament)

Create a new single-level tournament instance.

Event Emitted: tournamentCreated(ITournament) when tournament is created

Parameters:

NameTypeDescription
initialHashMachine.HashInitial machine state hash
providerIDataProviderData provider for input validation

Returns:

NameTypeDescription
tournamentITournamentCreated tournament instance

instantiate() (MultiLevelTournamentFactory)

function instantiate(Machine.Hash initialHash, IDataProvider provider) external returns (ITournament)

Create a new multi-level tournament hierarchy starting with a top tournament.

Event Emitted: tournamentCreated(ITournament) when tournament is created

Parameters:

NameTypeDescription
initialHashMachine.HashInitial machine state hash
providerIDataProviderData provider for input validation

Returns:

NameTypeDescription
tournamentITournamentCreated top tournament instance

instantiateTop()

function instantiateTop(Machine.Hash initialHash, IDataProvider provider) external returns (Tournament)

Create a new top-level tournament in the multi-level hierarchy.

Parameters:

NameTypeDescription
initialHashMachine.HashInitial machine state hash
providerIDataProviderData provider for input validation

Returns:

NameTypeDescription
tournamentTournamentCreated top tournament instance

instantiateMiddle()

function instantiateMiddle(Machine.Hash initialHash, Tree.Node contestedCommitmentOne, Machine.Hash contestedFinalStateOne, Tree.Node contestedCommitmentTwo, Machine.Hash contestedFinalStateTwo, Time.Duration allowance, uint256 startCycle, uint64 level, IDataProvider provider) external returns (Tournament)

Create a new middle-level tournament for dispute resolution.

Parameters:

NameTypeDescription
initialHashMachine.HashInitial machine state hash
contestedCommitmentOneTree.NodeFirst contested commitment
contestedFinalStateOneMachine.HashFirst contested final state
contestedCommitmentTwoTree.NodeSecond contested commitment
contestedFinalStateTwoMachine.HashSecond contested final state
allowanceTime.DurationTime allowance for participants
startCycleuint256Starting cycle for the tournament
leveluint64Tournament level in hierarchy
providerIDataProviderData provider for input validation

Returns:

NameTypeDescription
tournamentTournamentCreated middle tournament instance

instantiateBottom()

function instantiateBottom(Machine.Hash initialHash, Tree.Node contestedCommitmentOne, Machine.Hash contestedFinalStateOne, Tree.Node contestedCommitmentTwo, Machine.Hash contestedFinalStateTwo, Time.Duration allowance, uint256 startCycle, uint64 level, IDataProvider provider) external returns (Tournament)

Create a new bottom-level tournament for leaf dispute resolution.

Parameters:

NameTypeDescription
initialHashMachine.HashInitial machine state hash
contestedCommitmentOneTree.NodeFirst contested commitment
contestedFinalStateOneMachine.HashFirst contested final state
contestedCommitmentTwoTree.NodeSecond contested commitment
contestedFinalStateTwoMachine.HashSecond contested final state
allowanceTime.DurationTime allowance for participants
startCycleuint256Starting cycle for the tournament
leveluint64Tournament level in hierarchy
providerIDataProviderData provider for input validation

Returns:

NameTypeDescription
tournamentTournamentCreated bottom tournament instance
We use cookies to ensure that we give you the best experience on our website. By using the website, you agree to the use of cookies.