Skip to content

Commit 26e37b1

Browse files
committed
Merge branch 'fix(contracts)/remove-court-subcourt-naming-inconsistencies' of github.com:kleros/kleros-v2 into fix(contracts)/remove-court-subcourt-naming-inconsistencies
2 parents cb2ae4a + 1ee8762 commit 26e37b1

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

contracts/deploy/01-foreign-gateway.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enum ForeignChains {
1010

1111
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1212
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
13-
const { deploy } = deployments;
13+
const { deploy, execute } = deployments;
1414
const { hexZeroPad, hexlify } = ethers.utils;
1515

1616
// fallback to hardhat node signers on local network
@@ -38,17 +38,19 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
3838
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
3939
from: deployer,
4040
contract: "ForeignGateway",
41-
args: [
42-
deployer,
43-
veaReceiver.address,
44-
[ethers.BigNumber.from(10).pow(17)],
45-
homeGatewayAddress,
46-
homeChainIdAsBytes32,
47-
],
41+
args: [deployer, veaReceiver.address, homeGatewayAddress, homeChainIdAsBytes32],
4842
gasLimit: 4000000,
4943
log: true,
5044
});
5145

46+
await execute(
47+
"ForeignGatewayOnEthereum",
48+
{ from: deployer, log: true },
49+
"changeSubcourtJurorFee",
50+
0,
51+
ethers.BigNumber.from(10).pow(17)
52+
);
53+
5254
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/${hre.network.name}/MetaEvidence_ArbitrableExample.json`;
5355

5456
await deploy("ArbitrableExample", {

contracts/deploy/03-vea-mock.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const HARDHAT_NETWORK = 31337;
99

1010
const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1111
const { ethers, deployments, getNamedAccounts } = hre;
12-
const { deploy } = deployments;
12+
const { deploy, execute } = deployments;
1313
const { hexZeroPad, hexlify } = ethers.utils;
1414

1515
// fallback to hardhat node signers on local network
@@ -31,7 +31,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3131
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
3232
from: deployer,
3333
contract: "ForeignGateway",
34-
args: [deployer, vea.address, [ethers.BigNumber.from(10).pow(17)], homeGatewayAddress, homeChainIdAsBytes32],
34+
args: [deployer, vea.address, homeGatewayAddress, homeChainIdAsBytes32],
3535
gasLimit: 4000000,
3636
log: true,
3737
}); // nonce+0
@@ -44,6 +44,14 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
4444
log: true,
4545
}); // nonce+1
4646

47+
await execute(
48+
"ForeignGatewayOnEthereum",
49+
{ from: deployer, log: true },
50+
"changeSubcourtJurorFee",
51+
0,
52+
ethers.BigNumber.from(10).pow(17)
53+
);
54+
4755
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/goerli/MetaEvidence_ArbitrableExample.json`;
4856

4957
await deploy("ArbitrableExample", {

contracts/src/gateway/ForeignGateway.sol

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ contract ForeignGateway is IForeignGateway {
4343
address arbitrable
4444
);
4545

46+
event ArbitrationCostModified(uint96 indexed _courtID, uint256 _feeForJuror);
47+
4648
// ************************************* //
4749
// * Storage * //
4850
// ************************************* //
@@ -51,7 +53,7 @@ contract ForeignGateway is IForeignGateway {
5153
uint256 public immutable override senderChainID;
5254
address public immutable override senderGateway;
5355
uint256 internal localDisputeID = 1; // The disputeID must start from 1 as the KlerosV1 proxy governor depends on this implementation. We now also depend on localDisputeID not ever being zero.
54-
uint256[] internal feeForJuror; // feeForJuror[courtID]
56+
mapping(uint96 => uint256) public feeForJuror; // feeForJuror[courtID], it mirrors the value on KlerosCore.
5557
address public governor;
5658
IFastBridgeReceiver public fastBridgeReceiver;
5759
IFastBridgeReceiver public depreciatedFastbridge;
@@ -79,13 +81,11 @@ contract ForeignGateway is IForeignGateway {
7981
constructor(
8082
address _governor,
8183
IFastBridgeReceiver _fastBridgeReceiver,
82-
uint256[] memory _feeForJuror,
8384
address _senderGateway,
8485
uint256 _senderChainID
8586
) {
8687
governor = _governor;
8788
fastBridgeReceiver = _fastBridgeReceiver;
88-
feeForJuror = _feeForJuror;
8989
senderGateway = _senderGateway;
9090
senderChainID = _senderChainID;
9191
}
@@ -111,16 +111,9 @@ contract ForeignGateway is IForeignGateway {
111111
* @param _courtID The ID of the court.
112112
* @param _feeForJuror The new value for the `feeForJuror` property value.
113113
*/
114-
function changeCourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor {
114+
function changeSubcourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor {
115115
feeForJuror[_courtID] = _feeForJuror;
116-
}
117-
118-
/**
119-
* @dev Creates the `feeForJuror` property value for a new court.
120-
* @param _feeForJuror The new value for the `feeForJuror` property value.
121-
*/
122-
function createCourtJurorFee(uint256 _feeForJuror) external onlyByGovernor {
123-
feeForJuror.push(_feeForJuror);
116+
emit ArbitrationCostModified(_courtID, _feeForJuror);
124117
}
125118

126119
// ************************************* //
@@ -163,8 +156,7 @@ contract ForeignGateway is IForeignGateway {
163156
}
164157

165158
function arbitrationCost(bytes calldata _extraData) public view override returns (uint256 cost) {
166-
(uint96 courtID, uint256 minJurors) = extraDataToCourtIDMinJurors(_extraData);
167-
159+
(uint96 courtID, uint256 minJurors) = extraDataToSubcourtIDMinJurors(_extraData);
168160
cost = feeForJuror[courtID] * minJurors;
169161
}
170162

@@ -212,7 +204,7 @@ contract ForeignGateway is IForeignGateway {
212204
// * Internal * //
213205
// ************************ //
214206

215-
function extraDataToCourtIDMinJurors(
207+
function extraDataToSubcourtIDMinJurors(
216208
bytes memory _extraData
217209
) internal view returns (uint96 courtID, uint256 minJurors) {
218210
// Note that here we ignore DisputeKitID
@@ -222,7 +214,7 @@ contract ForeignGateway is IForeignGateway {
222214
courtID := mload(add(_extraData, 0x20))
223215
minJurors := mload(add(_extraData, 0x40))
224216
}
225-
if (courtID >= feeForJuror.length) courtID = 0;
217+
if (feeForJuror[courtID] == 0) courtID = 0;
226218
if (minJurors == 0) minJurors = MIN_JURORS;
227219
} else {
228220
courtID = 0;

0 commit comments

Comments
 (0)