Skip to content

Commit b15eb47

Browse files
committed
fixup! refactor(prt-contracts): merge (non)rootTournament into Tournament
1 parent f734050 commit b15eb47

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

cartesi-rollups/contracts/test/DaveConsensus.t.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ contract MockTournament is ITournament {
142142
revert NotImplemented();
143143
}
144144

145-
function tournamentArguments() external pure override returns (ITournament.TournamentArguments memory) {
145+
function tournamentArguments() external pure override returns (TournamentArguments memory) {
146+
revert NotImplemented();
147+
}
148+
149+
function nonRootTournamentArgs() external pure override returns (NonRootArguments memory) {
146150
revert NotImplemented();
147151
}
148152

prt/client-lua/player/reader.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function Reader:inner_tournament_winner(address)
369369
local winner = {
370370
has_winner = helper.str_to_bool(ret[1]),
371371
parent_commitment = Hash:from_digest_hex(ret[2]),
372-
dangling_commitment = Hash:from_digest_hex(ret[3]),
372+
commitment = Hash:from_digest_hex(ret[3]),
373373
-- ret[4] contains Clock.State struct (allowance, startInstant) if needed
374374
}
375375

prt/contracts/src/ITournament.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ interface ITournament {
431431
view
432432
returns (TournamentArguments memory);
433433

434+
/// @notice Returns non-root tournament arguments
435+
function nonRootTournamentArgs()
436+
external
437+
view
438+
returns (NonRootArguments memory);
439+
434440
/// @notice Check whether a match can be won by timeout.
435441
/// @param matchId The match ID
436442
function canWinMatchByTimeout(Match.Id calldata matchId)

prt/contracts/src/tournament/abstracts/Tournament.sol

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ abstract contract Tournament is ITournament {
114114
/// NON-ROOT TOURNAMENT (level > 0):
115115
/// - Must override this function to return the actual contested final states
116116
/// - These are stored in the tournament's argument struct
117-
function _nonRootTournamentArgs()
118-
internal
117+
function nonRootTournamentArgs()
118+
public
119119
view
120120
virtual
121-
returns (ITournament.NonRootArguments memory)
121+
returns (NonRootArguments memory)
122122
{
123123
// Default implementation for root tournaments (level == 0)
124124
// Non-root tournaments (level > 0) must override this
125-
return ITournament.NonRootArguments({
125+
return NonRootArguments({
126126
contestedCommitmentOne: Tree.ZERO_NODE,
127127
contestedFinalStateOne: Machine.ZERO_STATE,
128128
contestedCommitmentTwo: Tree.ZERO_NODE,
@@ -159,7 +159,7 @@ abstract contract Tournament is ITournament {
159159
// NON-ROOT CASE: level > 0
160160
// Non-root tournaments only accept commitments that match one of the two
161161
// contested final states from the parent match
162-
NonRootArguments memory nonRootArgs = _nonRootTournamentArgs();
162+
NonRootArguments memory nonRootArgs = nonRootTournamentArgs();
163163
return (
164164
nonRootArgs.contestedFinalStateOne.eq(_finalState)
165165
|| nonRootArgs.contestedFinalStateTwo.eq(_finalState),
@@ -170,16 +170,6 @@ abstract contract Tournament is ITournament {
170170

171171
function _totalGasEstimate() internal view virtual returns (uint256);
172172

173-
//
174-
// Helper Functions
175-
//
176-
177-
/// @notice Check if this is a root tournament (level == 0)
178-
function _isRootTournament() internal view returns (bool) {
179-
TournamentArguments memory args = tournamentArguments();
180-
return args.level == 0;
181-
}
182-
183173
//
184174
// Methods
185175
//
@@ -737,7 +727,7 @@ abstract contract Tournament is ITournament {
737727

738728
// Map the winning final state to one of the two contested final states
739729
// from the parent match
740-
NonRootArguments memory nonRootArgs = _nonRootTournamentArgs();
730+
NonRootArguments memory nonRootArgs = nonRootTournamentArgs();
741731
Machine.Hash _finalState = finalStates[_winner];
742732

743733
if (_finalState.eq(nonRootArgs.contestedFinalStateOne)) {

prt/contracts/src/tournament/concretes/BottomTournament.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ import {IStateTransition} from "prt-contracts/IStateTransition.sol";
99
import {
1010
LeafTournament
1111
} from "prt-contracts/tournament/abstracts/LeafTournament.sol";
12-
import {Tournament} from "prt-contracts/tournament/abstracts/Tournament.sol";
1312

1413
/// @notice Bottom tournament of a multi-level instance
1514
contract BottomTournament is LeafTournament {
1615
using Clones for address;
1716

1817
struct BottomArguments {
1918
TournamentArguments tournamentArgs;
20-
Tournament.NonRootArguments nonRootTournamentArgs;
19+
NonRootArguments nonRootTournamentArgs;
2120
IStateTransition stateTransition;
2221
}
2322

@@ -34,11 +33,11 @@ contract BottomTournament is LeafTournament {
3433
return _bottomArgs().tournamentArgs;
3534
}
3635

37-
function _nonRootTournamentArgs()
38-
internal
36+
function nonRootTournamentArgs()
37+
public
3938
view
4039
override
41-
returns (Tournament.NonRootArguments memory)
40+
returns (NonRootArguments memory)
4241
{
4342
return _bottomArgs().nonRootTournamentArgs;
4443
}

prt/contracts/src/tournament/concretes/MiddleTournament.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {Clones} from "@openzeppelin-contracts-5.5.0/proxy/Clones.sol";
88
import {
99
NonLeafTournament
1010
} from "prt-contracts/tournament/abstracts/NonLeafTournament.sol";
11-
import {Tournament} from "prt-contracts/tournament/abstracts/Tournament.sol";
1211
import {
1312
IMultiLevelTournamentFactory
1413
} from "prt-contracts/tournament/factories/IMultiLevelTournamentFactory.sol";
@@ -19,7 +18,7 @@ contract MiddleTournament is NonLeafTournament {
1918

2019
struct MiddleArguments {
2120
TournamentArguments tournamentArgs;
22-
Tournament.NonRootArguments nonRootTournamentArgs;
21+
NonRootArguments nonRootTournamentArgs;
2322
IMultiLevelTournamentFactory tournamentFactory;
2423
}
2524

@@ -36,11 +35,11 @@ contract MiddleTournament is NonLeafTournament {
3635
return _middleArgs().tournamentArgs;
3736
}
3837

39-
function _nonRootTournamentArgs()
40-
internal
38+
function nonRootTournamentArgs()
39+
public
4140
view
4241
override
43-
returns (Tournament.NonRootArguments memory)
42+
returns (NonRootArguments memory)
4443
{
4544
return _middleArgs().nonRootTournamentArgs;
4645
}

0 commit comments

Comments
 (0)