Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contracts/deploy/00-home-chain-arbitration-neo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
args: [core.target, disputeTemplateRegistry.target],
log: true,
});
console.log(`core.changeArbitrableWhitelistEnabled(true)`);
await core.changeArbitrableWhitelistEnabled(true);
console.log(`core.changeArbitrableWhitelist(${resolver.address}, true)`);
await core.changeArbitrableWhitelist(resolver.address, true);

Expand Down
1,282 changes: 1,269 additions & 13 deletions contracts/src/arbitration/KlerosCore.sol

Large diffs are not rendered by default.

1,275 changes: 0 additions & 1,275 deletions contracts/src/arbitration/KlerosCoreBase.sol

This file was deleted.

138 changes: 0 additions & 138 deletions contracts/src/arbitration/KlerosCoreNeo.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.24;

import {KlerosCore, KlerosCoreBase, IDisputeKit, ISortitionModule} from "../KlerosCore.sol";
import {KlerosCore, IDisputeKit, ISortitionModule} from "../KlerosCore.sol";
import {Initializable} from "../../proxy/Initializable.sol";
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
import {SafeSend} from "../../libraries/SafeSend.sol";
Expand Down Expand Up @@ -273,7 +273,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
bytes32 _commit
) internal notJumped(_coreDisputeID) {
(, , KlerosCore.Period period, , ) = core.disputes(_coreDisputeID);
if (period != KlerosCoreBase.Period.commit) revert NotCommitPeriod();
if (period != KlerosCore.Period.commit) revert NotCommitPeriod();
if (_commit == bytes32(0)) revert EmptyCommit();
if (!coreDisputeIDToActive[_coreDisputeID]) revert NotActiveForCoreDisputeID();

Expand Down Expand Up @@ -314,7 +314,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
address _juror
) internal notJumped(_coreDisputeID) {
(, , KlerosCore.Period period, , ) = core.disputes(_coreDisputeID);
if (period != KlerosCoreBase.Period.vote) revert NotVotePeriod();
if (period != KlerosCore.Period.vote) revert NotVotePeriod();
if (_voteIDs.length == 0) revert EmptyVoteIDs();
if (!coreDisputeIDToActive[_coreDisputeID]) revert NotActiveForCoreDisputeID();

Expand Down Expand Up @@ -517,7 +517,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
ruling = tied ? 0 : round.winningChoice;
(, , KlerosCore.Period period, , ) = core.disputes(_coreDisputeID);
// Override the final ruling if only one side funded the appeals.
if (period == KlerosCoreBase.Period.execution) {
if (period == KlerosCore.Period.execution) {
uint256[] memory fundedChoices = getFundedChoices(_coreDisputeID);
if (fundedChoices.length == 1) {
ruling = fundedChoices[0];
Expand Down
12 changes: 0 additions & 12 deletions contracts/src/proxy/KlerosProxies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import "./UUPSProxy.sol";
/// Workaround to get meaningful names for the proxy contracts
/// Otherwise all the contracts are called `UUPSProxy` on the chain explorers

contract DisputeKitClassicNeoProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}

contract DisputeKitClassicUniversityProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}
Expand Down Expand Up @@ -51,10 +47,6 @@ contract HomeGatewayToEthereumProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}

contract KlerosCoreNeoProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}

contract KlerosCoreRulerProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}
Expand All @@ -75,10 +67,6 @@ contract RandomizerRNGProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}

contract SortitionModuleNeoProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}

contract SortitionModuleUniversityProxy is UUPSProxy {
constructor(address _implementation, bytes memory _data) UUPSProxy(_implementation, _data) {}
}
Expand Down
98 changes: 68 additions & 30 deletions contracts/test/arbitration/staking-neo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,60 +128,98 @@ describe("Staking", async () => {
SHOULD BEHAVE LIKE A NEO ARBITRATOR
************************************************************************************************/

describe("When arbitrable is not whitelisted", () => {
describe("When arbitrable whitelist is disabled", () => {
before("Setup", async () => {
await deployUnhappy();
await core.changeArbitrableWhitelist(resolver.target, false);
await core.changeArbitrableWhitelistEnabled(false);
});

it("Should fail to create a dispute", async () => {
it("Should create a dispute", async () => {
const arbitrationCost = ETH(0.5);
await expect(
resolver.createDisputeForTemplate(extraData, "", "", 2, { value: arbitrationCost })
).to.be.revertedWithCustomError(core, "ArbitrableNotWhitelisted");
expect(await resolver.createDisputeForTemplate(extraData, "", "", 2, { value: arbitrationCost }))
.to.emit(core, "DisputeCreation")
.withArgs(0, resolver.target);
});
});

describe("When arbitrable is whitelisted", () => {
describe("When arbitrable whitelist is enabled", () => {
before("Setup", async () => {
await deployUnhappy();
await core.changeArbitrableWhitelist(resolver.target, true);
await core.changeArbitrableWhitelistEnabled(true);
});

it("Should create a dispute", async () => {
const arbitrationCost = ETH(0.5);
expect(await resolver.createDisputeForTemplate(extraData, "", "", 2, { value: arbitrationCost }))
.to.emit(core, "DisputeCreation")
.withArgs(0, resolver.target);
describe("When arbitrable is not whitelisted", () => {
before("Setup", async () => {
await core.changeArbitrableWhitelist(resolver.target, false);
});

it("Should fail to create a dispute", async () => {
const arbitrationCost = ETH(0.5);
await expect(
resolver.createDisputeForTemplate(extraData, "", "", 2, { value: arbitrationCost })
).to.be.revertedWithCustomError(core, "ArbitrableNotWhitelisted");
});
});

describe("When arbitrable is whitelisted", () => {
before("Setup", async () => {
await core.changeArbitrableWhitelist(resolver.target, true);
});

it("Should create a dispute", async () => {
const arbitrationCost = ETH(0.5);
expect(await resolver.createDisputeForTemplate(extraData, "", "", 2, { value: arbitrationCost }))
.to.emit(core, "DisputeCreation")
.withArgs(0, resolver.target);
});
});
});

describe("When juror has no NFT", async () => {
describe("When juror NFT is not set", async () => {
before("Setup", async () => {
await deployUnhappy();
await core.changeJurorNft(ethers.ZeroAddress);
});

it("Should not be able to stake", async () => {
await pnk.connect(juror).approve(core.target, PNK(1000));
await expect(core.connect(juror).setStake(1, PNK(1000))).to.be.revertedWithCustomError(
core,
"NotEligibleForStaking"
);
describe("When juror has no NFT", async () => {
it("Should be able to stake", async () => {
await pnk.connect(juror).approve(core.target, PNK(1000));
await expect(await core.connect(juror).setStake(1, PNK(1000)))
.to.emit(sortition, "StakeSet")
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
});
});
});

describe("When juror does have a NFT", async () => {
before("Setup", async () => {
await deployUnhappy();
await nft.safeMint(juror.address);
describe("When juror NFT is set", async () => {
describe("When juror has no NFT", async () => {
before("Setup", async () => {
await deployUnhappy();
});

it("Should not be able to stake", async () => {
await pnk.connect(juror).approve(core.target, PNK(1000));
await expect(core.connect(juror).setStake(1, PNK(1000))).to.be.revertedWithCustomError(
core,
"NotEligibleForStaking"
);
});
});

it("Should be able to stake", async () => {
await pnk.connect(juror).approve(core.target, PNK(1000));
await expect(await core.connect(juror).setStake(1, PNK(1000)))
.to.emit(sortition, "StakeSet")
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
describe("When juror does have a NFT", async () => {
before("Setup", async () => {
await deployUnhappy();
await nft.safeMint(juror.address);
});

it("Should be able to stake", async () => {
await pnk.connect(juror).approve(core.target, PNK(1000));
await expect(await core.connect(juror).setStake(1, PNK(1000)))
.to.emit(sortition, "StakeSet")
.withArgs(juror.address, 1, PNK(1000), PNK(1000));
expect(await sortition.totalStaked()).to.be.equal(PNK(1000));
});
});
});

Expand Down
Loading
Loading