Skip to content

Commit 61fc72c

Browse files
author
hurstelm
committed
fix(arbitration): all tests run correctly
1 parent cf1f23b commit 61fc72c

14 files changed

+33
-26
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3232
deployer, // governor
3333
pnk.target,
3434
[minStake, alpha, feeForJuror, jurorsForCourtJump],
35+
weth.target,
3536
],
3637
log: true,
3738
});

contracts/src/arbitration/KlerosCore.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract KlerosCore is KlerosCoreBase {
1515
// ************************************* //
1616

1717
/// @custom:oz-upgrades-unsafe-allow constructor
18-
constructor() {
18+
constructor() KlerosCoreBase(address(0)) {
1919
_disableInitializers();
2020
}
2121

contracts/src/arbitration/KlerosCoreBase.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
88
import {Initializable} from "../proxy/Initializable.sol";
99
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
1010
import {SafeERC20, IERC20} from "../libraries/SafeERC20.sol";
11-
import {WethLike, SafeSend} from "../libraries/SafeSend.sol";
11+
import {SafeSend} from "../libraries/SafeSend.sol";
1212
import "../libraries/Constants.sol";
1313

1414
/// @title KlerosCoreBase
@@ -192,7 +192,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
192192
// * Constructor * //
193193
// ************************************* //
194194

195-
/**
195+
/**
196196
* @dev This contract is deployed only once per chain, as the logic master contract.
197197
* New instances are created with minimal proxy from the factory.
198198
* This is only needed to set the wrapped native token, which is used in SafeSend.
@@ -201,7 +201,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
201201
*/
202202
constructor(address _wNative) {
203203
W_NATIVE = _wNative;
204-
}
204+
}
205205

206206
function __KlerosCoreBase_initialize(
207207
address _governor,
@@ -213,7 +213,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
213213
uint256[4] memory _courtParameters,
214214
uint256[4] memory _timesPerPeriod,
215215
bytes memory _sortitionExtraData,
216-
ISortitionModule _sortitionModuleAddress,
216+
ISortitionModule _sortitionModuleAddress
217217
) internal onlyInitializing {
218218
governor = _governor;
219219
guardian = _guardian;

contracts/src/arbitration/KlerosCoreNeo.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract KlerosCoreNeo is KlerosCoreBase {
2323
// ************************************* //
2424

2525
/// @custom:oz-upgrades-unsafe-allow constructor
26-
constructor() {
26+
constructor() KlerosCoreBase(address(0)) {
2727
_disableInitializers();
2828
}
2929

contracts/src/arbitration/KlerosGovernor.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pragma solidity ^0.8.24;
44

55
import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitrableV2.sol";
6-
import {WethLike, SafeSend} from "../libraries/SafeSend.sol";
6+
import {SafeSend} from "../libraries/SafeSend.sol";
77
import "./interfaces/IDisputeTemplateRegistry.sol";
88

99
/// @title KlerosGovernor for V2. Note that appeal functionality and evidence submission will be handled by the court.

contracts/src/arbitration/devtools/KlerosCoreRuler.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.24;
44

55
import {IArbitrableV2, IArbitratorV2} from "../interfaces/IArbitratorV2.sol";
66
import {SafeERC20, IERC20} from "../../libraries/SafeERC20.sol";
7-
import {WethLike, SafeSend} from "../../libraries/SafeSend.sol";
7+
import {SafeSend} from "../../libraries/SafeSend.sol";
88
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
99
import {Initializable} from "../../proxy/Initializable.sol";
1010
import "../../libraries/Constants.sol";
@@ -87,6 +87,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
8787

8888
uint256 private constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2) / 2; // An amount higher than the supply of ETH.
8989

90+
address public governor; // The governor of the contract.
9091
IERC20 public pinakion; // The Pinakion token contract.
9192
Court[] public courts; // The courts.
9293
Dispute[] public disputes; // The disputes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contract DisputeKitClassic is DisputeKitClassicBase {
1818
// ************************************* //
1919

2020
/// @custom:oz-upgrades-unsafe-allow constructor
21-
constructor() {
21+
constructor() DisputeKitClassicBase(address(0)) {
2222
_disableInitializers();
2323
}
2424

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pragma solidity ^0.8.24;
55
import {KlerosCore, KlerosCoreBase, IDisputeKit, ISortitionModule} from "../KlerosCore.sol";
66
import {Initializable} from "../../proxy/Initializable.sol";
77
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
8-
import {WethLike, SafeSend} from "../../libraries/SafeSend.sol";
8+
import {SafeSend} from "../../libraries/SafeSend.sol";
99

1010
/// @title DisputeKitClassicBase
1111
/// Abstract Dispute kit classic implementation of the Kleros v1 features including:
@@ -59,7 +59,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
5959
uint256 public constant ONE_BASIS_POINT = 10000; // One basis point, for scaling.
6060

6161
address public governor; // The governor of the contract.
62-
address public wNative; // The address for WETH tranfers.
62+
address immutable W_NATIVE; // The address for WETH tranfers.
6363
KlerosCore public core; // The Kleros Core arbitrator
6464
Dispute[] public disputes; // Array of the locally created disputes.
6565
mapping(uint256 => uint256) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID.
@@ -142,18 +142,23 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
142142
// * Constructor * //
143143
// ************************************* //
144144

145+
/**
146+
* @dev This contract is deployed only once per chain, as the logic master contract.
147+
* New instances are created with minimal proxy from the factory.
148+
* This is only needed to set the wrapped native token, which is used in SafeSend.
149+
* Since it is constant per chain, it can be safely set as immutable to optimize gas usage.
150+
* @param _wNative The Wrapped Native Token on this chain.
151+
*/
152+
constructor(address _wNative) {
153+
W_NATIVE = _wNative;
154+
}
155+
145156
/// @dev Initializer.
146157
/// @param _governor The governor's address.
147158
/// @param _core The KlerosCore arbitrator.
148-
/// @param _wNative The address of the WETH used by SafeSend for fallback transfers.
149-
function __DisputeKitClassicBase_initialize(
150-
address _governor,
151-
KlerosCore _core,
152-
address _wNative
153-
) internal onlyInitializing {
159+
function __DisputeKitClassicBase_initialize(address _governor, KlerosCore _core) internal onlyInitializing {
154160
governor = _governor;
155161
core = _core;
156-
wNative = _wNative;
157162
}
158163

159164
// ************************ //
@@ -418,7 +423,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
418423
core.appeal{value: appealCost}(_coreDisputeID, dispute.numberOfChoices, dispute.extraData);
419424
}
420425

421-
if (msg.value > contribution) SafeSend.safeSend(payable(msg.sender), msg.value - contribution, wNative);
426+
if (msg.value > contribution) SafeSend.safeSend(payable(msg.sender), msg.value - contribution, W_NATIVE);
422427
}
423428

424429
/// @dev Allows those contributors who attempted to fund an appeal round to withdraw any reimbursable fees or rewards after the dispute gets resolved.
@@ -463,7 +468,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
463468
round.contributions[_beneficiary][_choice] = 0;
464469

465470
if (amount != 0) {
466-
SafeSend.safeSend(_beneficiary, amount, wNative); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
471+
SafeSend.safeSend(_beneficiary, amount, W_NATIVE); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
467472
emit Withdrawal(_coreDisputeID, _coreRoundID, _choice, _beneficiary, amount);
468473
}
469474
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract DisputeKitGated is DisputeKitClassicBase {
3434
// ************************************* //
3535

3636
/// @custom:oz-upgrades-unsafe-allow constructor
37-
constructor() {
37+
constructor() DisputeKitClassicBase(address(0)) {
3838
_disableInitializers();
3939
}
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ contract DisputeKitGatedShutter is DisputeKitClassicBase {
5353
// ************************************* //
5454

5555
/// @custom:oz-upgrades-unsafe-allow constructor
56-
constructor() {
56+
constructor() DisputeKitClassicBase(address(0)) {
5757
_disableInitializers();
5858
}
5959

0 commit comments

Comments
 (0)