Skip to content

Commit e4d4bdb

Browse files
feat(KlerosCore): allow to jump to a non-classic DK
1 parent f734873 commit e4d4bdb

File tree

11 files changed

+86
-30
lines changed

11 files changed

+86
-30
lines changed

contracts/deploy/00-home-chain-arbitration-neo.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2828

2929
await deployUpgradable(deployments, "EvidenceModule", { from: deployer, args: [deployer], log: true });
3030

31+
const jumpDisputeKitID = 1; // Classic DK
3132
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
3233
from: deployer,
3334
contract: "DisputeKitClassic",
34-
args: [deployer, ZeroAddress, weth.target],
35+
args: [deployer, ZeroAddress, weth.target, jumpDisputeKitID],
3536
log: true,
3637
});
3738

@@ -124,21 +125,21 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
124125
// Extra dispute kits
125126
const disputeKitShutter = await deployUpgradable(deployments, "DisputeKitShutter", {
126127
from: deployer,
127-
args: [deployer, core.target, weth.target],
128+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
128129
log: true,
129130
});
130131
await core.addNewDisputeKit(disputeKitShutter.address);
131132

132133
const disputeKitGated = await deployUpgradable(deployments, "DisputeKitGated", {
133134
from: deployer,
134-
args: [deployer, core.target, weth.target],
135+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
135136
log: true,
136137
});
137138
await core.addNewDisputeKit(disputeKitGated.address);
138139

139140
const disputeKitGatedShutter = await deployUpgradable(deployments, "DisputeKitGatedShutter", {
140141
from: deployer,
141-
args: [deployer, core.target, weth.target],
142+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
142143
log: true,
143144
});
144145
await core.addNewDisputeKit(disputeKitGatedShutter.address);

contracts/deploy/00-home-chain-arbitration.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3434
log: true,
3535
});
3636

37+
const jumpDisputeKitID = 1; // Classic DK
3738
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
3839
from: deployer,
39-
args: [deployer, ZeroAddress, weth.target],
40+
args: [deployer, ZeroAddress, weth.target, jumpDisputeKitID],
4041
log: true,
4142
});
4243

@@ -105,23 +106,23 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
105106
// Extra dispute kits
106107
const disputeKitShutter = await deployUpgradable(deployments, "DisputeKitShutter", {
107108
from: deployer,
108-
args: [deployer, core.target, weth.target],
109+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
109110
log: true,
110111
});
111112
await core.addNewDisputeKit(disputeKitShutter.address);
112113
await core.enableDisputeKits(Courts.GENERAL, [2], true); // enable disputeKitShutter on the General Court
113114

114115
const disputeKitGated = await deployUpgradable(deployments, "DisputeKitGated", {
115116
from: deployer,
116-
args: [deployer, core.target, weth.target],
117+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
117118
log: true,
118119
});
119120
await core.addNewDisputeKit(disputeKitGated.address);
120121
await core.enableDisputeKits(Courts.GENERAL, [3], true); // enable disputeKitGated on the General Court
121122

122123
const disputeKitGatedShutter = await deployUpgradable(deployments, "DisputeKitGatedShutter", {
123124
from: deployer,
124-
args: [deployer, core.target, weth.target],
125+
args: [deployer, core.target, weth.target, jumpDisputeKitID],
125126
log: true,
126127
});
127128
await core.addNewDisputeKit(disputeKitGatedShutter.address);

contracts/src/arbitration/KlerosCoreBase.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,11 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
10791079
courtJump = true;
10801080

10811081
if (!courts[newCourtID].supportedDisputeKits[newDisputeKitID]) {
1082-
// Switch to classic dispute kit if parent court doesn't support the current one.
1083-
newDisputeKitID = DISPUTE_KIT_CLASSIC;
1082+
newDisputeKitID = disputeKits[_round.disputeKitID].getJumpDisputeKitID();
1083+
if (!courts[newCourtID].supportedDisputeKits[newDisputeKitID]) {
1084+
// Switch to classic dispute kit if parent court doesn't support the jump DK.
1085+
newDisputeKitID = DISPUTE_KIT_CLASSIC;
1086+
}
10841087
disputeKitJump = true;
10851088
}
10861089
}

contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ contract DisputeKitClassic is DisputeKitClassicBase {
2626
/// @param _owner The owner's address.
2727
/// @param _core The KlerosCore arbitrator.
2828
/// @param _wNative The wrapped native token address, typically wETH.
29-
function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) {
30-
__DisputeKitClassicBase_initialize(_owner, _core, _wNative);
29+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
30+
function initialize(
31+
address _owner,
32+
KlerosCore _core,
33+
address _wNative,
34+
uint256 _jumpDisputeKitID
35+
) external reinitializer(1) {
36+
__DisputeKitClassicBase_initialize(_owner, _core, _wNative, _jumpDisputeKitID);
3137
}
3238

3339
function reinitialize(address _wNative) external reinitializer(9) {

contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {KlerosCore, KlerosCoreBase, IDisputeKit, ISortitionModule} from "../Kler
66
import {Initializable} from "../../proxy/Initializable.sol";
77
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
88
import {SafeSend} from "../../libraries/SafeSend.sol";
9-
import {ONE_BASIS_POINT} from "../../libraries/Constants.sol";
9+
import {ONE_BASIS_POINT, DISPUTE_KIT_CLASSIC} from "../../libraries/Constants.sol";
1010

1111
/// @title DisputeKitClassicBase
1212
/// Abstract Dispute kit classic implementation of the Kleros v1 features including:
@@ -68,6 +68,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
6868
public alreadyDrawn; // True if the address has already been drawn, false by default. To be added to the Round struct when fully redeploying rather than upgrading.
6969
mapping(uint256 coreDisputeID => bool) public coreDisputeIDToActive; // True if this dispute kit is active for this core dispute ID.
7070
address public wNative; // The wrapped native token for safeSend().
71+
uint256 public jumpDisputeKitID; // The ID of the dispute kit in Kleros Core disputeKits array that the dispute should switch to after the court jump, in case the new court doesn't support this dispute kit.
7172

7273
// ************************************* //
7374
// * Events * //
@@ -147,14 +148,17 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
147148
/// @param _owner The owner's address.
148149
/// @param _core The KlerosCore arbitrator.
149150
/// @param _wNative The wrapped native token address, typically wETH.
151+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
150152
function __DisputeKitClassicBase_initialize(
151153
address _owner,
152154
KlerosCore _core,
153-
address _wNative
155+
address _wNative,
156+
uint256 _jumpDisputeKitID
154157
) internal onlyInitializing {
155158
owner = _owner;
156159
core = _core;
157160
wNative = _wNative;
161+
jumpDisputeKitID = _jumpDisputeKitID;
158162
}
159163

160164
// ************************ //
@@ -176,6 +180,12 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
176180
owner = _owner;
177181
}
178182

183+
/// @dev Changes the dispute kit ID used for the jump.
184+
/// @param _jumpDisputeKitID The new value for the `jumpDisputeKitID` storage variable.
185+
function changeJumpDisputeKitID(uint256 _jumpDisputeKitID) external onlyByOwner {
186+
jumpDisputeKitID = _jumpDisputeKitID;
187+
}
188+
179189
/// @dev Changes the `core` storage variable.
180190
/// @param _core The new value for the `core` storage variable.
181191
function changeCore(address _core) external onlyByOwner {
@@ -639,6 +649,11 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
639649
return (_currentNbVotes * 2) + 1;
640650
}
641651

652+
function getJumpDisputeKitID() external view returns (uint256) {
653+
// Fall back to classic DK in case the jump ID is not defined.
654+
return jumpDisputeKitID == 0 ? DISPUTE_KIT_CLASSIC : jumpDisputeKitID;
655+
}
656+
642657
/// @dev Returns true if the specified voter was active in this round.
643658
/// @param _coreDisputeID The ID of the dispute in Kleros Core, not in the Dispute Kit.
644659
/// @param _coreRoundID The ID of the round in Kleros Core, not in the Dispute Kit.

contracts/src/arbitration/dispute-kits/DisputeKitGated.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ contract DisputeKitGated is DisputeKitClassicBase {
4242
/// @param _owner The owner's address.
4343
/// @param _core The KlerosCore arbitrator.
4444
/// @param _wNative The wrapped native token address, typically wETH.
45-
function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) {
46-
__DisputeKitClassicBase_initialize(_owner, _core, _wNative);
45+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
46+
function initialize(
47+
address _owner,
48+
KlerosCore _core,
49+
address _wNative,
50+
uint256 _jumpDisputeKitID
51+
) external reinitializer(1) {
52+
__DisputeKitClassicBase_initialize(_owner, _core, _wNative, _jumpDisputeKitID);
4753
}
4854

4955
function reinitialize(address _wNative) external reinitializer(9) {

contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ contract DisputeKitGatedShutter is DisputeKitClassicBase {
6161
/// @param _owner The owner's address.
6262
/// @param _core The KlerosCore arbitrator.
6363
/// @param _wNative The wrapped native token address, typically wETH.
64-
function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) {
65-
__DisputeKitClassicBase_initialize(_owner, _core, _wNative);
64+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
65+
function initialize(
66+
address _owner,
67+
KlerosCore _core,
68+
address _wNative,
69+
uint256 _jumpDisputeKitID
70+
) external reinitializer(1) {
71+
__DisputeKitClassicBase_initialize(_owner, _core, _wNative, _jumpDisputeKitID);
6672
}
6773

6874
function reinitialize(address _wNative) external reinitializer(9) {

contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ contract DisputeKitShutter is DisputeKitClassicBase {
4545
/// @param _owner The owner's address.
4646
/// @param _core The KlerosCore arbitrator.
4747
/// @param _wNative The wrapped native token address, typically wETH.
48-
function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) {
49-
__DisputeKitClassicBase_initialize(_owner, _core, _wNative);
48+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
49+
function initialize(
50+
address _owner,
51+
KlerosCore _core,
52+
address _wNative,
53+
uint256 _jumpDisputeKitID
54+
) external reinitializer(1) {
55+
__DisputeKitClassicBase_initialize(_owner, _core, _wNative, _jumpDisputeKitID);
5056
}
5157

5258
function reinitialize(address _wNative) external reinitializer(9) {

contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ contract DisputeKitSybilResistant is DisputeKitClassicBase {
4040
/// @param _core The KlerosCore arbitrator.
4141
/// @param _poh The Proof of Humanity registry.
4242
/// @param _wNative The wrapped native token address, typically wETH.
43+
/// @param _jumpDisputeKitID The ID of the dispute kit to switch to after the court jump.
4344
function initialize(
4445
address _owner,
4546
KlerosCore _core,
4647
IProofOfHumanity _poh,
47-
address _wNative
48+
address _wNative,
49+
uint256 _jumpDisputeKitID
4850
) external reinitializer(1) {
49-
__DisputeKitClassicBase_initialize(_owner, _core, _wNative);
51+
__DisputeKitClassicBase_initialize(_owner, _core, _wNative, _jumpDisputeKitID);
5052
poh = _poh;
5153
singleDrawPerJuror = true;
5254
}

contracts/src/arbitration/interfaces/IDisputeKit.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ interface IDisputeKit {
127127
uint256 _currentNbVotes
128128
) external view returns (uint256); // TODO: remove previousDisputeKit
129129

130+
/// @dev Returns the dispute kid ID for Kleros Core, that will be used after court jump.
131+
/// @return The ID of the dispute kit in Kleros Core disputeKits array.
132+
function getJumpDisputeKitID() external view returns (uint256);
133+
130134
/// @dev Returns true if the specified voter was active in this round.
131135
/// @param _coreDisputeID The ID of the dispute in Kleros Core, not in the Dispute Kit.
132136
/// @param _coreRoundID The ID of the round in Kleros Core, not in the Dispute Kit.

0 commit comments

Comments
 (0)