Skip to content

Commit 40714da

Browse files
committed
feat: only SortitionModule, no more SortitionModuleBase and SortitionModuleNeo
1 parent bd210be commit 40714da

File tree

9 files changed

+622
-713
lines changed

9 files changed

+622
-713
lines changed

contracts/src/arbitration/SortitionModule.sol

Lines changed: 582 additions & 5 deletions
Large diffs are not rendered by default.

contracts/src/arbitration/SortitionModuleBase.sol

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

contracts/src/arbitration/SortitionModuleNeo.sol

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

contracts/test/foundry/KlerosCore_Drawing.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.24;
33

44
import {KlerosCore_TestBase} from "./KlerosCore_TestBase.sol";
55
import {KlerosCore} from "../../src/arbitration/KlerosCore.sol";
6-
import {SortitionModuleBase} from "../../src/arbitration/SortitionModuleBase.sol";
6+
import {SortitionModule} from "../../src/arbitration/SortitionModule.sol";
77
import {ISortitionModule} from "../../src/arbitration/interfaces/ISortitionModule.sol";
88
import "../../src/libraries/Constants.sol";
99

@@ -24,7 +24,7 @@ contract KlerosCore_DrawingTest is KlerosCore_TestBase {
2424
sortitionModule.passPhase(); // Drawing phase
2525

2626
vm.expectEmit(true, true, true, true);
27-
emit SortitionModuleBase.StakeLocked(staker1, 1000, false);
27+
emit SortitionModule.StakeLocked(staker1, 1000, false);
2828
vm.expectEmit(true, true, true, true);
2929
emit KlerosCore.Draw(staker1, disputeID, roundID, 0); // VoteID = 0
3030

contracts/test/foundry/KlerosCore_Execution.t.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.24;
33

44
import {KlerosCore_TestBase} from "./KlerosCore_TestBase.sol";
55
import {KlerosCore} from "../../src/arbitration/KlerosCore.sol";
6-
import {SortitionModuleBase} from "../../src/arbitration/SortitionModuleBase.sol";
6+
import {SortitionModule} from "../../src/arbitration/SortitionModule.sol";
77
import {DisputeKitClassicBase} from "../../src/arbitration/dispute-kits/DisputeKitClassicBase.sol";
88
import {IArbitratorV2, IArbitrableV2} from "../../src/arbitration/KlerosCore.sol";
99
import {IERC20} from "../../src/libraries/SafeERC20.sol";
@@ -96,16 +96,16 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
9696
);
9797

9898
vm.expectEmit(true, true, true, true);
99-
emit SortitionModuleBase.StakeLocked(staker1, 1000, true);
99+
emit SortitionModule.StakeLocked(staker1, 1000, true);
100100
vm.expectEmit(true, true, true, true);
101101
emit KlerosCore.TokenAndETHShift(staker1, disputeID, 0, 0, -int256(1000), 0, IERC20(address(0)));
102102
// Check iterations for the winning staker to see the shifts
103103
vm.expectEmit(true, true, true, true);
104-
emit SortitionModuleBase.StakeLocked(staker2, 0, true);
104+
emit SortitionModule.StakeLocked(staker2, 0, true);
105105
vm.expectEmit(true, true, true, true);
106106
emit KlerosCore.TokenAndETHShift(staker2, disputeID, 0, 10000, 0, 0, IERC20(address(0)));
107107
vm.expectEmit(true, true, true, true);
108-
emit SortitionModuleBase.StakeLocked(staker2, 0, true);
108+
emit SortitionModule.StakeLocked(staker2, 0, true);
109109
vm.expectEmit(true, true, true, true);
110110
emit KlerosCore.TokenAndETHShift(staker2, disputeID, 0, 10000, 0, 0, IERC20(address(0)));
111111
core.execute(disputeID, 0, 3); // Do 3 iterations to check penalties first
@@ -121,16 +121,16 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
121121
assertEq(round.pnkPenalties, 1000, "Wrong pnkPenalties");
122122

123123
vm.expectEmit(true, true, true, true);
124-
emit SortitionModuleBase.StakeLocked(staker1, 0, true);
124+
emit SortitionModule.StakeLocked(staker1, 0, true);
125125
vm.expectEmit(true, true, true, true);
126126
emit KlerosCore.TokenAndETHShift(staker1, disputeID, 0, 0, 0, 0, IERC20(address(0)));
127127
// Check iterations for the winning staker to see the shifts
128128
vm.expectEmit(true, true, true, true);
129-
emit SortitionModuleBase.StakeLocked(staker2, 1000, true);
129+
emit SortitionModule.StakeLocked(staker2, 1000, true);
130130
vm.expectEmit(true, true, true, true);
131131
emit KlerosCore.TokenAndETHShift(staker2, disputeID, 0, 10000, 500, 0.045 ether, IERC20(address(0)));
132132
vm.expectEmit(true, true, true, true);
133-
emit SortitionModuleBase.StakeLocked(staker2, 1000, true);
133+
emit SortitionModule.StakeLocked(staker2, 1000, true);
134134
vm.expectEmit(true, true, true, true);
135135
emit KlerosCore.TokenAndETHShift(staker2, disputeID, 0, 10000, 500, 0.045 ether, IERC20(address(0)));
136136
core.execute(disputeID, 0, 10); // Finish the iterations. We need only 3 but check that it corrects the count.
@@ -272,11 +272,11 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
272272

273273
// Note that these events are emitted only after the first iteration of execute() therefore the juror has been penalized only for 1000 PNK her.
274274
vm.expectEmit(true, true, true, true);
275-
emit SortitionModuleBase.StakeSet(staker1, newCourtID, 19000, 39000); // 1000 PNK penalty for voteID 0
275+
emit SortitionModule.StakeSet(staker1, newCourtID, 19000, 39000); // 1000 PNK penalty for voteID 0
276276
vm.expectEmit(true, true, true, true);
277-
emit SortitionModuleBase.StakeSet(staker1, newCourtID, 0, 20000); // Starting with 40000 we first nullify the stake and remove 19000 and then remove penalty once since there was only first iteration (40000 - 20000 - 1000)
277+
emit SortitionModule.StakeSet(staker1, newCourtID, 0, 20000); // Starting with 40000 we first nullify the stake and remove 19000 and then remove penalty once since there was only first iteration (40000 - 20000 - 1000)
278278
vm.expectEmit(true, true, true, true);
279-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 0, 2000); // 2000 PNK should remain in balance to cover penalties since the first 1000 of locked pnk was already unlocked
279+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 0, 2000); // 2000 PNK should remain in balance to cover penalties since the first 1000 of locked pnk was already unlocked
280280
core.execute(disputeID, 0, 3);
281281

282282
assertEq(pinakion.balanceOf(address(core)), 0, "Wrong token balance of the core");
@@ -335,7 +335,7 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
335335
core.passPeriod(disputeID); // Execution
336336

337337
vm.expectEmit(true, true, true, true);
338-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 0, 0); // Juror should have no stake left and should be unstaked from the court automatically.
338+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 0, 0); // Juror should have no stake left and should be unstaked from the court automatically.
339339
core.execute(disputeID, 0, 6);
340340

341341
assertEq(pinakion.balanceOf(address(core)), 0, "Wrong token balance of the core");
@@ -397,7 +397,7 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
397397
core.passPeriod(disputeID); // Execution
398398

399399
vm.expectEmit(true, true, true, true);
400-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 0, 0); // Juror balance should be below minStake and should be unstaked from the court automatically.
400+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 0, 0); // Juror balance should be below minStake and should be unstaked from the court automatically.
401401
core.execute(disputeID, 0, 6);
402402

403403
assertEq(pinakion.balanceOf(address(core)), 11000, "Wrong token balance of the core");
@@ -460,11 +460,11 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
460460
assertEq(pinakion.balanceOf(address(core)), 1000, "Wrong token balance of the core");
461461
assertEq(pinakion.balanceOf(staker1), 999999999999999000, "Wrong token balance of staker1");
462462

463-
vm.expectRevert(SortitionModuleBase.NotEligibleForWithdrawal.selector);
463+
vm.expectRevert(SortitionModule.NotEligibleForWithdrawal.selector);
464464
sortitionModule.withdrawLeftoverPNK(staker1);
465465

466466
vm.expectEmit(true, true, true, true);
467-
emit SortitionModuleBase.LeftoverPNK(staker1, 1000);
467+
emit SortitionModule.LeftoverPNK(staker1, 1000);
468468
core.execute(disputeID, 0, 6);
469469

470470
(totalStaked, totalLocked, , ) = sortitionModule.getJurorBalance(staker1, GENERAL_COURT);
@@ -485,7 +485,7 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
485485
core.transferBySortitionModule(staker1, 1000);
486486

487487
vm.expectEmit(true, true, true, true);
488-
emit SortitionModuleBase.LeftoverPNKWithdrawn(staker1, 1000);
488+
emit SortitionModule.LeftoverPNKWithdrawn(staker1, 1000);
489489
sortitionModule.withdrawLeftoverPNK(staker1);
490490

491491
(totalStaked, , , ) = sortitionModule.getJurorBalance(staker1, GENERAL_COURT);

contracts/test/foundry/KlerosCore_Initialization.t.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ contract KlerosCore_InitializationTest is KlerosCore_TestBase {
123123
DisputeKitClassic newDisputeKit = DisputeKitClassic(address(proxyDk));
124124

125125
bytes memory initDataSm = abi.encodeWithSignature(
126-
"initialize(address,address,uint256,uint256,address)",
126+
"initialize(address,address,uint256,uint256,address,uint256,uint256)",
127127
newOwner,
128128
address(proxyCore),
129129
newMinStakingTime,
130130
newMaxDrawingTime,
131-
newRng
131+
newRng,
132+
type(int256).max,
133+
type(int256).max
132134
);
133135

134136
UUPSProxy proxySm = new UUPSProxy(address(smLogic), initDataSm);

contracts/test/foundry/KlerosCore_RNG.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.24;
33

44
import {KlerosCore_TestBase} from "./KlerosCore_TestBase.sol";
5-
import {SortitionModuleBase} from "../../src/arbitration/SortitionModuleBase.sol";
5+
import {SortitionModule} from "../../src/arbitration/SortitionModule.sol";
66
import {RNGWithFallback, IRNG} from "../../src/rng/RNGWithFallback.sol";
77
import {RNGMock} from "../../src/test/RNGMock.sol";
88
import "../../src/libraries/Constants.sol";
@@ -34,7 +34,7 @@ contract KlerosCore_RNGTest is KlerosCore_TestBase {
3434
sortitionModule.passPhase(); // Generating
3535
assertEq(rngFallback.requestTimestamp(), block.timestamp, "Wrong request timestamp");
3636

37-
vm.expectRevert(SortitionModuleBase.RandomNumberNotReady.selector);
37+
vm.expectRevert(SortitionModule.RandomNumberNotReady.selector);
3838
sortitionModule.passPhase();
3939

4040
vm.warp(block.timestamp + fallbackTimeout + 1);

contracts/test/foundry/KlerosCore_Staking.t.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.24;
33

44
import {KlerosCore_TestBase} from "./KlerosCore_TestBase.sol";
55
import {KlerosCore} from "../../src/arbitration/KlerosCore.sol";
6-
import {SortitionModuleBase} from "../../src/arbitration/SortitionModuleBase.sol";
6+
import {SortitionModule} from "../../src/arbitration/SortitionModule.sol";
77
import {ISortitionModule} from "../../src/arbitration/interfaces/ISortitionModule.sol";
88
import {IKlerosCore, KlerosCoreSnapshotProxy} from "../../src/arbitration/view/KlerosCoreSnapshotProxy.sol";
99
import "../../src/libraries/Constants.sol";
@@ -39,7 +39,7 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
3939

4040
vm.prank(staker1);
4141
vm.expectEmit(true, true, true, true);
42-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 1001, 1001);
42+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 1001, 1001);
4343
core.setStake(GENERAL_COURT, 1001);
4444

4545
(uint256 totalStaked, uint256 totalLocked, uint256 stakedInCourt, uint256 nbCourts) = sortitionModule
@@ -65,7 +65,7 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
6565
// Increase stake one more time to verify the correct behavior
6666
vm.prank(staker1);
6767
vm.expectEmit(true, true, true, true);
68-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 2000, 2000);
68+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 2000, 2000);
6969
core.setStake(GENERAL_COURT, 2000);
7070

7171
(totalStaked, totalLocked, stakedInCourt, nbCourts) = sortitionModule.getJurorBalance(staker1, GENERAL_COURT);
@@ -188,7 +188,7 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
188188

189189
vm.prank(staker1);
190190
vm.expectEmit(true, true, true, true);
191-
emit SortitionModuleBase.StakeDelayed(staker1, GENERAL_COURT, 1500);
191+
emit SortitionModule.StakeDelayed(staker1, GENERAL_COURT, 1500);
192192
core.setStake(GENERAL_COURT, 1500);
193193

194194
uint256 delayedStakeId = sortitionModule.delayedStakeWriteIndex();
@@ -234,7 +234,7 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
234234

235235
vm.prank(staker1);
236236
vm.expectEmit(true, true, true, true);
237-
emit SortitionModuleBase.StakeDelayed(staker1, GENERAL_COURT, 1800);
237+
emit SortitionModule.StakeDelayed(staker1, GENERAL_COURT, 1800);
238238
core.setStake(GENERAL_COURT, 1800);
239239

240240
(uint256 totalStaked, , uint256 stakedInCourt, ) = sortitionModule.getJurorBalance(staker1, GENERAL_COURT);
@@ -301,7 +301,7 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
301301
vm.prank(staker2);
302302
core.setStake(GENERAL_COURT, 10000);
303303

304-
vm.expectRevert(SortitionModuleBase.NoDelayedStakeToExecute.selector);
304+
vm.expectRevert(SortitionModule.NoDelayedStakeToExecute.selector);
305305
sortitionModule.executeDelayedStakes(5);
306306

307307
// Set the stake and create a dispute to advance the phase
@@ -314,13 +314,13 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
314314
uint256 disputeID = 0;
315315
core.draw(disputeID, DEFAULT_NB_OF_JURORS);
316316

317-
vm.expectRevert(SortitionModuleBase.NotStakingPhase.selector);
317+
vm.expectRevert(SortitionModule.NotStakingPhase.selector);
318318
sortitionModule.executeDelayedStakes(5);
319319

320320
// Create delayed stake
321321
vm.prank(staker1);
322322
vm.expectEmit(true, true, true, true);
323-
emit SortitionModuleBase.StakeDelayed(staker1, GENERAL_COURT, 1500);
323+
emit SortitionModule.StakeDelayed(staker1, GENERAL_COURT, 1500);
324324
core.setStake(GENERAL_COURT, 1500);
325325

326326
assertEq(pinakion.balanceOf(address(core)), 10000, "Wrong token balance of the core"); // Balance should not increase because the stake was delayed
@@ -329,14 +329,14 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
329329
// Create delayed stake for another staker
330330
vm.prank(staker2);
331331
vm.expectEmit(true, true, true, true);
332-
emit SortitionModuleBase.StakeDelayed(staker2, GENERAL_COURT, 0);
332+
emit SortitionModule.StakeDelayed(staker2, GENERAL_COURT, 0);
333333
core.setStake(GENERAL_COURT, 0);
334334
assertEq(pinakion.balanceOf(staker2), 999999999999990000, "Wrong token balance of staker2"); // Balance should not change since wrong phase
335335

336336
// Create another delayed stake for staker1 on top of it to check the execution
337337
vm.prank(staker1);
338338
vm.expectEmit(true, true, true, true);
339-
emit SortitionModuleBase.StakeDelayed(staker1, GENERAL_COURT, 1800);
339+
emit SortitionModule.StakeDelayed(staker1, GENERAL_COURT, 1800);
340340
core.setStake(GENERAL_COURT, 1800);
341341

342342
assertEq(sortitionModule.delayedStakeWriteIndex(), 3, "Wrong delayedStakeWriteIndex");
@@ -384,9 +384,9 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase {
384384

385385
// 2 events should be emitted but the 2nd stake supersedes the first one in the end.
386386
vm.expectEmit(true, true, true, true);
387-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 1500, 1500);
387+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 1500, 1500);
388388
vm.expectEmit(true, true, true, true);
389-
emit SortitionModuleBase.StakeSet(staker1, GENERAL_COURT, 1800, 1800);
389+
emit SortitionModule.StakeSet(staker1, GENERAL_COURT, 1800, 1800);
390390
sortitionModule.executeDelayedStakes(20); // Deliberately ask for more iterations than needed
391391

392392
assertEq(sortitionModule.delayedStakeWriteIndex(), 3, "Wrong delayedStakeWriteIndex");

0 commit comments

Comments
 (0)