Skip to content

Commit 63be21f

Browse files
committed
refactor(prt-contracts): merge (non)leafTournament into Tournament
1 parent e78fbb4 commit 63be21f

19 files changed

+599
-1172
lines changed

prt/client-rs/core/src/tournament/reader.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::tournament::{
1616
TournamentWinner,
1717
};
1818
use cartesi_dave_merkle::Digest;
19-
use cartesi_prt_contracts::{non_leaf_tournament, tournament};
19+
use cartesi_prt_contracts::tournament;
2020

2121
#[derive(Clone)]
2222
pub struct StateReader {
@@ -37,8 +37,7 @@ impl StateReader {
3737
tournament_address: Address,
3838
match_id: MatchID,
3939
) -> Result<Option<TournamentCreatedEvent>> {
40-
let tournament =
41-
non_leaf_tournament::NonLeafTournament::new(tournament_address, &self.client);
40+
let tournament = tournament::Tournament::new(tournament_address, &self.client);
4241
let events = tournament
4342
.NewInnerTournament_filter()
4443
.address(tournament_address)

prt/client-rs/core/src/tournament/sender.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ruint::aliases::U256;
1414

1515
use crate::{machine::MachineProof, tournament::MatchID};
1616
use cartesi_dave_merkle::{Digest, MerkleProof};
17-
use cartesi_prt_contracts::{leaf_tournament, non_leaf_tournament, tournament};
17+
use cartesi_prt_contracts::tournament;
1818

1919
#[derive(Clone, Debug)]
2020
pub struct EthArenaSender {
@@ -167,7 +167,7 @@ impl ArenaSender for EthArenaSender {
167167
right_leaf: Digest,
168168
initial_hash_proof: &MerkleProof,
169169
) -> Result<()> {
170-
let tournament = non_leaf_tournament::NonLeafTournament::new(tournament, &self.provider);
170+
let tournament = tournament::Tournament::new(tournament, &self.provider);
171171
let initial_hash_siblings = initial_hash_proof
172172
.siblings
173173
.iter()
@@ -193,7 +193,7 @@ impl ArenaSender for EthArenaSender {
193193
left_node: Digest,
194194
right_node: Digest,
195195
) -> Result<()> {
196-
let tournament = non_leaf_tournament::NonLeafTournament::new(tournament, &self.provider);
196+
let tournament = tournament::Tournament::new(tournament, &self.provider);
197197
let tx_result = tournament
198198
.winInnerTournament(child_tournament, left_node.into(), right_node.into())
199199
.send()
@@ -208,7 +208,7 @@ impl ArenaSender for EthArenaSender {
208208
left_node: Digest,
209209
right_node: Digest,
210210
) -> Result<()> {
211-
let tournament = non_leaf_tournament::NonLeafTournament::new(tournament, &self.provider);
211+
let tournament = tournament::Tournament::new(tournament, &self.provider);
212212
let tx_result = tournament
213213
.winMatchByTimeout(match_id.into(), left_node.into(), right_node.into())
214214
.send()
@@ -224,7 +224,7 @@ impl ArenaSender for EthArenaSender {
224224
right_leaf: Digest,
225225
initial_hash_proof: &MerkleProof,
226226
) -> Result<()> {
227-
let tournament = leaf_tournament::LeafTournament::new(tournament, &self.provider);
227+
let tournament = tournament::Tournament::new(tournament, &self.provider);
228228
let initial_hash_siblings = initial_hash_proof
229229
.siblings
230230
.iter()
@@ -251,7 +251,7 @@ impl ArenaSender for EthArenaSender {
251251
right_node: Digest,
252252
proofs: MachineProof,
253253
) -> Result<()> {
254-
let tournament = leaf_tournament::LeafTournament::new(tournament, &self.provider);
254+
let tournament = tournament::Tournament::new(tournament, &self.provider);
255255
let tx_result = tournament
256256
.winLeafMatch(
257257
match_id.into(),
@@ -278,7 +278,7 @@ impl ArenaSender for EthArenaSender {
278278
tournament: Address,
279279
inner_tournament: Address,
280280
) -> Result<()> {
281-
let tournament = non_leaf_tournament::NonLeafTournament::new(tournament, &self.provider);
281+
let tournament = tournament::Tournament::new(tournament, &self.provider);
282282
let tx_result = tournament
283283
.eliminateInnerTournament(inner_tournament)
284284
.send()

prt/client-rs/core/src/tournament/tournament.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ impl From<MatchID> for cartesi_prt_contracts::tournament::Match::Id {
3434
}
3535
}
3636

37-
impl From<MatchID> for cartesi_prt_contracts::non_leaf_tournament::Match::Id {
38-
fn from(match_id: MatchID) -> Self {
39-
cartesi_prt_contracts::non_leaf_tournament::Match::Id {
40-
commitmentOne: match_id.commitment_one.into(),
41-
commitmentTwo: match_id.commitment_two.into(),
42-
}
43-
}
44-
}
45-
46-
impl From<MatchID> for cartesi_prt_contracts::leaf_tournament::Match::Id {
47-
fn from(match_id: MatchID) -> Self {
48-
cartesi_prt_contracts::leaf_tournament::Match::Id {
49-
commitmentOne: match_id.commitment_one.into(),
50-
commitmentTwo: match_id.commitment_two.into(),
51-
}
52-
}
53-
}
54-
5537
/// Struct used to communicate the state of a commitment.
5638
#[derive(Clone, Copy, Debug)]
5739
pub struct CommitmentState {

prt/contracts/justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BINDINGS_DIR := "./bindings-rs/src/contract"
22
DEPLOYMENTS_DIR := "./deployments"
33
SRC_DIR := "."
4-
BINDINGS_FILTER := "^[^I].+TournamentFactory|LeafTournament|^Tournament$"
4+
BINDINGS_FILTER := "^[^I].+TournamentFactory|^Tournament$"
55

66
default: build
77

prt/contracts/script/Deployment.s.sol

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,10 @@ import {
2323
import {
2424
RiscVStateTransition
2525
} from "src/state-transition/RiscVStateTransition.sol";
26-
import {BottomTournament} from "src/tournament/concretes/BottomTournament.sol";
27-
import {MiddleTournament} from "src/tournament/concretes/MiddleTournament.sol";
28-
import {TopTournament} from "src/tournament/concretes/TopTournament.sol";
26+
import {Tournament} from "src/tournament/concretes/Tournament.sol";
2927
import {
3028
MultiLevelTournamentFactory
3129
} from "src/tournament/factories/MultiLevelTournamentFactory.sol";
32-
import {
33-
BottomTournamentFactory
34-
} from "src/tournament/factories/multilevel/BottomTournamentFactory.sol";
35-
import {
36-
MiddleTournamentFactory
37-
} from "src/tournament/factories/multilevel/MiddleTournamentFactory.sol";
38-
import {
39-
TopTournamentFactory
40-
} from "src/tournament/factories/multilevel/TopTournamentFactory.sol";
4130
import {Time} from "src/tournament/libs/Time.sol";
4231

4332
type Milliseconds is uint64;
@@ -188,43 +177,9 @@ contract DeploymentScript is BaseDeploymentScript {
188177
)
189178
);
190179

191-
address topTournament = _storeDeployment(
192-
type(TopTournament).name,
193-
_create2(type(TopTournament).creationCode, abi.encode())
194-
);
195-
196-
address middleTournament = _storeDeployment(
197-
type(MiddleTournament).name,
198-
_create2(type(MiddleTournament).creationCode, abi.encode())
199-
);
200-
201-
address bottomTournament = _storeDeployment(
202-
type(BottomTournament).name,
203-
_create2(type(BottomTournament).creationCode, abi.encode())
204-
);
205-
206-
address topTournamentFactory = _storeDeployment(
207-
type(TopTournamentFactory).name,
208-
_create2(
209-
type(TopTournamentFactory).creationCode,
210-
abi.encode(topTournament)
211-
)
212-
);
213-
214-
address middleTournamentFactory = _storeDeployment(
215-
type(MiddleTournamentFactory).name,
216-
_create2(
217-
type(MiddleTournamentFactory).creationCode,
218-
abi.encode(middleTournament)
219-
)
220-
);
221-
222-
address bottomTournamentFactory = _storeDeployment(
223-
type(BottomTournamentFactory).name,
224-
_create2(
225-
type(BottomTournamentFactory).creationCode,
226-
abi.encode(bottomTournament)
227-
)
180+
address tournamentImpl = _storeDeployment(
181+
type(Tournament).name,
182+
_create2(type(Tournament).creationCode, abi.encode())
228183
);
229184

230185
address canonicalTournamentParametersProvider = _storeDeployment(
@@ -240,9 +195,7 @@ contract DeploymentScript is BaseDeploymentScript {
240195
_create2(
241196
type(MultiLevelTournamentFactory).creationCode,
242197
abi.encode(
243-
topTournamentFactory,
244-
middleTournamentFactory,
245-
bottomTournamentFactory,
198+
tournamentImpl,
246199
canonicalTournamentParametersProvider,
247200
cartesiStateTransition
248201
)

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

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)