Skip to content

Commit 1d2e62a

Browse files
committed
fix: dispute kit storage layout on testnet
1 parent 68f66a3 commit 1d2e62a

File tree

8 files changed

+165
-87
lines changed

8 files changed

+165
-87
lines changed

contracts/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
3535
- [ChainlinkRNG](https://sepolia.arbiscan.io/address/0xAd5cCc93429e3A977c273cEeD106Ef16A69EAf79)
3636
- [DAI](https://sepolia.arbiscan.io/address/0xc34aeFEa232956542C5b2f2EE55fD5c378B35c03)
3737
- [DAIFaucet](https://sepolia.arbiscan.io/address/0x1Fa58B52326488D62A406E71DBaD839560e810fF)
38-
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x0c38f115D001d3b5bBec5e8D44f78C7B61A27D94), [implementation](https://sepolia.arbiscan.io/address/0xdE697727BF5d72bbA1d854F95EC27D6e9D33baF6)
38+
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x0c38f115D001d3b5bBec5e8D44f78C7B61A27D94), [implementation](https://sepolia.arbiscan.io/address/0xBed62D71A93c7E4415dF9b32B9A8116CeEd23b28)
3939
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xed31bEE8b1F7cE89E93033C0d3B2ccF4cEb27652)
4040
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xe763d31Cb096B4bc7294012B78FC7F148324ebcb), [implementation](https://sepolia.arbiscan.io/address/0xf97791DA66e0A8Ff8Ee4908872CfCAcc641829Ec)
4141
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xA88A9a25cE7f1d8b3941dA3b322Ba91D009E1397), [implementation](https://sepolia.arbiscan.io/address/0xC4e64e6E949936a18269937FC1e18cb11E3db14D)

contracts/deploy/upgrade-all.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const deployUpgradeAll: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5050
}
5151
};
5252

53-
await upgrade(disputeKitClassic, "initialize5", []);
53+
await upgrade(disputeKitClassic, "initialize6", []);
5454
await upgrade(disputeTemplateRegistry, "initialize2", []);
5555
await upgrade(evidence, "initialize2", []);
5656
await upgrade(core, "initialize4", []);

contracts/deployments/arbitrumSepolia/DisputeKitClassic.json

+34-5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,35 @@
321321
"stateMutability": "view",
322322
"type": "function"
323323
},
324+
{
325+
"inputs": [
326+
{
327+
"internalType": "uint256",
328+
"name": "localDisputeID",
329+
"type": "uint256"
330+
},
331+
{
332+
"internalType": "uint256",
333+
"name": "localRoundID",
334+
"type": "uint256"
335+
},
336+
{
337+
"internalType": "address",
338+
"name": "drawnAddress",
339+
"type": "address"
340+
}
341+
],
342+
"name": "alreadyDrawn",
343+
"outputs": [
344+
{
345+
"internalType": "bool",
346+
"name": "",
347+
"type": "bool"
348+
}
349+
],
350+
"stateMutability": "view",
351+
"type": "function"
352+
},
324353
{
325354
"inputs": [
326355
{
@@ -837,7 +866,7 @@
837866
},
838867
{
839868
"inputs": [],
840-
"name": "initialize5",
869+
"name": "initialize6",
841870
"outputs": [],
842871
"stateMutability": "nonpayable",
843872
"type": "function"
@@ -1031,16 +1060,16 @@
10311060
"0xDb0B7908C46E2Bb08459bf9b3155b9bb8F8713E1",
10321061
"0x485cc955000000000000000000000000f1c7c037891525e360c59f708739ac09a7670c590000000000000000000000000000000000000000000000000000000000000000"
10331062
],
1034-
"numDeployments": 3,
1035-
"solcInputHash": "ddb1d73b37802d9c7aed4eea0e503ecc",
1063+
"numDeployments": 4,
1064+
"solcInputHash": "3097f5974b1c71468eeb05ef9f28e57e",
10361065
"metadata": "{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/proxy/KlerosProxies.sol\":\"DisputeKitClassicProxy\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":100},\"remappings\":[]},\"sources\":{\"src/proxy/KlerosProxies.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.24;\\n\\nimport \\\"./UUPSProxy.sol\\\";\\n\\n/// Workaround to get meaningful names for the proxy contracts\\n/// Otherwise all the contracts are called `UUPSProxy` on the chain explorers\\n\\ncontract DisputeKitClassicNeoProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract DisputeKitClassicUniversityProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract DisputeKitClassicProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract DisputeKitGatedProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract DisputeKitSybilResistantProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract DisputeTemplateRegistryProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract EvidenceModuleProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract ForeignGatewayOnEthereumProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract HomeGatewayToEthereumProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract KlerosCoreNeoProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract KlerosCoreRulerProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract KlerosCoreUniversityProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract KlerosCoreProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract PolicyRegistryProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract RandomizerRNGProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract SortitionModuleNeoProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract SortitionModuleUniversityProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\\ncontract SortitionModuleProxy is UUPSProxy {\\n constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}\\n}\\n\",\"keccak256\":\"0x8edb830825d7fe8ef85d445b087fac3b41f626cd7d5b40ea583c3cba21528687\",\"license\":\"MIT\"},\"src/proxy/UUPSProxy.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.24;\\n\\n/// @title UUPS Proxy\\n/// @author Simon Malatrait <[email protected]>\\n/// @dev This contract implements a UUPS Proxy compliant with ERC-1967 & ERC-1822.\\n/// @dev This contract delegates all calls to another contract (UUPS Proxiable) through a fallback function and the use of the `delegatecall` EVM instruction.\\n/// @dev We refer to the Proxiable contract (as per ERC-1822) with `implementation`.\\n/// @dev Adapted from <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/proxy/ERC1967/ERC1967Proxy.sol>\\ncontract UUPSProxy {\\n /// @dev Storage slot with the address of the current implementation.\\n /// This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n /// validated in the constructor.\\n /// NOTE: bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\\n bytes32 private constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n // ************************************* //\\n // * Constructor * //\\n // ************************************* //\\n\\n /// @dev Initializes the upgradeable proxy with an initial implementation specified by `_implementation`.\\n /// If `_data` is nonempty, it's used as data in a delegate call to `_implementation`. This will typically be an encoded\\n /// function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n constructor(address _implementation, bytes memory _data) {\\n assembly {\\n sstore(IMPLEMENTATION_SLOT, _implementation)\\n }\\n\\n if (_data.length != 0) {\\n (bool success, ) = _implementation.delegatecall(_data);\\n require(success, \\\"Proxy Constructor failed\\\");\\n }\\n }\\n\\n // ************************************* //\\n // * State Modifiers * //\\n // ************************************* //\\n\\n /// @dev Delegates the current call to `implementation`.\\n /// NOTE: This function does not return to its internal call site, it will return directly to the external caller.\\n function _delegate(address implementation) internal {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n // ************************************* //\\n // * Internal Views * //\\n // ************************************* //\\n\\n function _getImplementation() internal view returns (address implementation) {\\n assembly {\\n implementation := sload(IMPLEMENTATION_SLOT)\\n }\\n }\\n\\n // ************************************* //\\n // * Fallback * //\\n // ************************************* //\\n\\n /// @dev Fallback function that delegates calls to the address returned by `_implementation()`.\\n /// @dev Will run if no other function in the contract matches the call data.\\n fallback() external payable {\\n _delegate(_getImplementation());\\n }\\n\\n receive() external payable {\\n _delegate(_getImplementation());\\n }\\n}\\n\",\"keccak256\":\"0xc3e0b18f846a62cc6c274680fc10014d1267885f8eefc6767292d3e174a081c0\",\"license\":\"MIT\"}},\"version\":1}",
10371066
"bytecode": "0x608060405234801561001057600080fd5b5060405161030238038061030283398101604081905261002f91610151565b8181817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55805160001461010e576000826001600160a01b031682604051610077919061021f565b600060405180830381855af49150503d80600081146100b2576040519150601f19603f3d011682016040523d82523d6000602084013e6100b7565b606091505b505090508061010c5760405162461bcd60e51b815260206004820152601860248201527f50726f787920436f6e7374727563746f72206661696c65640000000000000000604482015260640160405180910390fd5b505b5050505061023b565b634e487b7160e01b600052604160045260246000fd5b60005b83811015610148578181015183820152602001610130565b50506000910152565b6000806040838503121561016457600080fd5b82516001600160a01b038116811461017b57600080fd5b60208401519092506001600160401b038082111561019857600080fd5b818501915085601f8301126101ac57600080fd5b8151818111156101be576101be610117565b604051601f8201601f19908116603f011681019083821181831017156101e6576101e6610117565b816040528281528860208487010111156101ff57600080fd5b61021083602083016020880161012d565b80955050505050509250929050565b6000825161023181846020870161012d565b9190910192915050565b60b9806102496000396000f3fe608060405236603757603560317f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6060565b005b603560317f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e808015607e573d6000f35b3d6000fdfea264697066735822122094a1c38a583896452ce447160bc2955480b6ba6592457d7be641c34e4339d47264736f6c63430008180033",
10381067
"deployedBytecode": "0x608060405236603757603560317f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6060565b005b603560317f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e808015607e573d6000f35b3d6000fdfea264697066735822122094a1c38a583896452ce447160bc2955480b6ba6592457d7be641c34e4339d47264736f6c63430008180033",
10391068
"execute": {
1040-
"methodName": "initialize5",
1069+
"methodName": "initialize6",
10411070
"args": []
10421071
},
1043-
"implementation": "0xdE697727BF5d72bbA1d854F95EC27D6e9D33baF6",
1072+
"implementation": "0xBed62D71A93c7E4415dF9b32B9A8116CeEd23b28",
10441073
"devdoc": {
10451074
"kind": "dev",
10461075
"methods": {},

contracts/deployments/arbitrumSepolia/DisputeKitClassic_Implementation.json

+114-71
Large diffs are not rendered by default.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {DisputeKitClassicBase, KlerosCore} from "./DisputeKitClassicBase.sol";
1111
/// - an incentive system: equal split between coherent votes,
1212
/// - an appeal system: fund 2 choices only, vote on any choice.
1313
contract DisputeKitClassic is DisputeKitClassicBase {
14-
string public constant override version = "0.9.3";
14+
string public constant override version = "0.10.0";
1515

1616
// ************************************* //
1717
// * Constructor * //
@@ -29,7 +29,7 @@ contract DisputeKitClassic is DisputeKitClassicBase {
2929
__DisputeKitClassicBase_initialize(_governor, _core);
3030
}
3131

32-
function initialize5() external reinitializer(5) {
32+
function initialize6() external reinitializer(6) {
3333
// NOP
3434
}
3535

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
3838
uint256 feeRewards; // Sum of reimbursable appeal fees available to the parties that made contributions to the ruling that ultimately wins a dispute.
3939
uint256[] fundedChoices; // Stores the choices that are fully funded.
4040
uint256 nbVotes; // Maximal number of votes this dispute can get.
41-
mapping(address drawnAddress => bool) alreadyDrawn; // Set to 'true' if the address has already been drawn, so it can't be drawn more than once.
4241
}
4342

4443
struct Vote {
@@ -62,6 +61,8 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
6261
Dispute[] public disputes; // Array of the locally created disputes.
6362
mapping(uint256 => uint256) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID.
6463
bool public singleDrawPerJuror; // Whether each juror can only draw once per dispute, false by default.
64+
mapping(uint256 localDisputeID => mapping(uint256 localRoundID => mapping(address drawnAddress => bool)))
65+
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.
6566

6667
// ************************************* //
6768
// * Events * //
@@ -215,8 +216,10 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
215216
uint256 _coreDisputeID,
216217
uint256 _nonce
217218
) external override onlyByCore notJumped(_coreDisputeID) returns (address drawnAddress) {
218-
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
219-
Round storage round = dispute.rounds[dispute.rounds.length - 1];
219+
uint256 localDisputeID = coreDisputeIDToLocal[_coreDisputeID];
220+
Dispute storage dispute = disputes[localDisputeID];
221+
uint256 localRoundID = dispute.rounds.length - 1;
222+
Round storage round = dispute.rounds[localRoundID];
220223

221224
ISortitionModule sortitionModule = core.sortitionModule();
222225
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
@@ -226,7 +229,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
226229

227230
if (_postDrawCheck(round, _coreDisputeID, drawnAddress)) {
228231
round.votes.push(Vote({account: drawnAddress, commit: bytes32(0), choice: 0, voted: false}));
229-
round.alreadyDrawn[drawnAddress] = true;
232+
alreadyDrawn[localDisputeID][localRoundID][drawnAddress] = true;
230233
} else {
231234
drawnAddress = address(0);
232235
}
@@ -626,7 +629,10 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
626629
result = totalStaked >= totalLocked + lockedAmountPerJuror;
627630

628631
if (singleDrawPerJuror) {
629-
result = result && !_round.alreadyDrawn[_juror];
632+
uint256 localDisputeID = coreDisputeIDToLocal[_coreDisputeID];
633+
Dispute storage dispute = disputes[localDisputeID];
634+
uint256 localRoundID = dispute.rounds.length - 1;
635+
result = result && !alreadyDrawn[localDisputeID][localRoundID][_juror];
630636
}
631637
}
632638
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface IBalanceHolderERC1155 {
2727
/// - an incentive system: equal split between coherent votes,
2828
/// - an appeal system: fund 2 choices only, vote on any choice.
2929
contract DisputeKitGated is DisputeKitClassicBase {
30-
string public constant override version = "0.9.3";
30+
string public constant override version = "0.10.0";
3131

3232
// ************************************* //
3333
// * Storage * //

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface IProofOfHumanity {
1818
/// - an incentive system: equal split between coherent votes,
1919
/// - an appeal system: fund 2 choices only, vote on any choice.
2020
contract DisputeKitSybilResistant is DisputeKitClassicBase {
21-
string public constant override version = "0.9.3";
21+
string public constant override version = "0.10.0";
2222

2323
// ************************************* //
2424
// * Storage * //

0 commit comments

Comments
 (0)