Skip to content

Commit

Permalink
fix: use different deposit values for challenger and requester
Browse files Browse the repository at this point in the history
  • Loading branch information
eccentricexit committed Feb 28, 2019
1 parent e0a25b2 commit 76a2c10
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 47 deletions.
33 changes: 22 additions & 11 deletions contracts/standard/permission/ArbitrableAddressList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {

// Settings
address public governor; // The address that can make governance changes to the parameters of the Address Curated Registry.
uint public challengeReward; // The deposit required for making and/or challenging a request. A party that wins a disputed request will have its deposit reimbursed and will receive the other's deposit.
uint public requesterBaseDeposit; // The base deposit to make a request.
uint public challengerBaseDeposit; // The base deposit to challenge a request.
uint public challengePeriodDuration; // The time before a request becomes executable if not challenged.
uint public metaEvidenceUpdates; // The number of times the meta evidence has been updated. Used to track the latest meta evidence ID.

Expand Down Expand Up @@ -158,7 +159,8 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {
* @param _registrationMetaEvidence The URI of the meta evidence object for registration requests.
* @param _clearingMetaEvidence The URI of the meta evidence object for clearing requests.
* @param _governor The trusted governor of this contract.
* @param _challengeReward The amount in wei required to submit or challenge a request.
* @param _requesterBaseDeposit The base deposit to make a request.
* @param _challengerBaseDeposit The base deposit to challenge a request.
* @param _challengePeriodDuration The time in seconds, parties have to challenge a request.
* @param _sharedStakeMultiplier Multiplier of the arbitration cost that each party must pay as fee stake for a round when there isn't a winner/loser in the previous round (e.g. when it's the first round or the arbitrator refused to or did not rule). In basis points.
* @param _winnerStakeMultiplier Multiplier of the arbitration cost that the winner has to pay as fee stake for a round in basis points.
Expand All @@ -170,7 +172,8 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {
string _registrationMetaEvidence,
string _clearingMetaEvidence,
address _governor,
uint _challengeReward,
uint _requesterBaseDeposit,
uint _challengerBaseDeposit,
uint _challengePeriodDuration,
uint _sharedStakeMultiplier,
uint _winnerStakeMultiplier,
Expand All @@ -180,7 +183,8 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {
emit MetaEvidence(1, _clearingMetaEvidence);

governor = _governor;
challengeReward = _challengeReward;
requesterBaseDeposit = _requesterBaseDeposit;
challengerBaseDeposit = _challengerBaseDeposit;
challengePeriodDuration = _challengePeriodDuration;
sharedStakeMultiplier = _sharedStakeMultiplier;
winnerStakeMultiplier = _winnerStakeMultiplier;
Expand Down Expand Up @@ -226,9 +230,9 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {

emit RequestSubmitted(_address, addr.status == AddressStatus.RegistrationRequested);

// Amount required to fully fund each side: challengeReward + arbitration cost + (arbitration cost * multiplier).
// Amount required to fully the requester: requesterBaseDeposit + arbitration cost + (arbitration cost * multiplier).
uint arbitrationCost = request.arbitrator.arbitrationCost(request.arbitratorExtraData);
uint totalCost = arbitrationCost.addCap((arbitrationCost.mulCap(sharedStakeMultiplier)) / MULTIPLIER_DIVISOR).addCap(challengeReward);
uint totalCost = arbitrationCost.addCap((arbitrationCost.mulCap(sharedStakeMultiplier)) / MULTIPLIER_DIVISOR).addCap(requesterBaseDeposit);
contribute(round, Party.Requester, msg.sender, msg.value, totalCost);
require(round.paidFees[uint(Party.Requester)] >= totalCost, "You must fully fund your side.");
round.hasPaid[uint(Party.Requester)] = true;
Expand Down Expand Up @@ -262,7 +266,7 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {

Round storage round = request.rounds[request.rounds.length - 1];
uint arbitrationCost = request.arbitrator.arbitrationCost(request.arbitratorExtraData);
uint totalCost = arbitrationCost.addCap((arbitrationCost.mulCap(sharedStakeMultiplier)) / MULTIPLIER_DIVISOR).addCap(challengeReward);
uint totalCost = arbitrationCost.addCap((arbitrationCost.mulCap(sharedStakeMultiplier)) / MULTIPLIER_DIVISOR).addCap(challengerBaseDeposit);
contribute(round, Party.Challenger, msg.sender, msg.value, totalCost);
require(round.paidFees[uint(Party.Challenger)] >= totalCost, "You must fully fund your side.");
round.hasPaid[uint(Party.Challenger)] = true;
Expand Down Expand Up @@ -507,11 +511,18 @@ contract ArbitrableAddressList is PermissionInterface, Arbitrable {
challengePeriodDuration = _challengePeriodDuration;
}

/** @dev Change the required amount required as a deposit to make or challenge a request.
* @param _challengeReward The new amount of wei required to make or challenge a request.
/** @dev Change the base amount required as a deposit to make a request.
* @param _requesterBaseDeposit The new base amount of wei required to make a request.
*/
function changeChallengeReward(uint _challengeReward) external onlyGovernor {
challengeReward = _challengeReward;
function changeRequesterBaseDeposit(uint _requesterBaseDeposit) external onlyGovernor {
requesterBaseDeposit = _requesterBaseDeposit;
}

/** @dev Change the base amount required as a deposit to challenge a request.
* @param _challengerBaseDeposit The new base amount of wei required to challenge a request.
*/
function changeChallengerBaseDeposit(uint _challengerBaseDeposit) external onlyGovernor {
challengerBaseDeposit = _challengerBaseDeposit;
}

/** @dev Change the governor of the token curated registry.
Expand Down
81 changes: 45 additions & 36 deletions test/arbitrable-address-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract('ArbitrableAddressList', function(accounts) {
const partyA = accounts[2]
const partyB = accounts[8]
const arbitratorExtraData = 0x08575
const challengeReward = 10 ** 10
const baseDeposit = 10 ** 10
const arbitrationCost = 1000
const sharedStakeMultiplier = 10000
const winnerStakeMultiplier = 20000
Expand Down Expand Up @@ -79,7 +79,8 @@ contract('ArbitrableAddressList', function(accounts) {
registrationMetaEvidence,
clearingMetaEvidence,
governor, // governor
challengeReward,
baseDeposit,
baseDeposit,
challengePeriodDuration,
sharedStakeMultiplier,
winnerStakeMultiplier,
Expand All @@ -104,7 +105,13 @@ contract('ArbitrableAddressList', function(accounts) {

const tx = await arbitrableAddressList.requestStatusChange(
submissionAddr,
{ from: partyA, value: challengeReward + arbitrationCost + (sharedStakeMultiplier * arbitrationCost) / 10000 }
{
from: partyA,
value:
baseDeposit +
arbitrationCost +
(sharedStakeMultiplier * arbitrationCost) / 10000
}
)

submissionAddress = tx.logs[0].args._address
Expand All @@ -113,7 +120,9 @@ contract('ArbitrableAddressList', function(accounts) {
it('request should have been placed', async () => {
assert.equal(
(await web3.eth.getBalance(arbitrableAddressList.address)).toNumber(),
challengeReward + arbitrationCost + (sharedStakeMultiplier * arbitrationCost)/10000
baseDeposit +
arbitrationCost +
(sharedStakeMultiplier * arbitrationCost) / 10000
)

const addr = await arbitrableAddressList.getAddressInfo(submissionAddress)
Expand All @@ -131,7 +140,9 @@ contract('ArbitrableAddressList', function(accounts) {
assert.isFalse(request[0])
assert.equal(
await web3.eth.getBalance(arbitrableAddressList.address),
challengeReward + arbitrationCost + (sharedStakeMultiplier * arbitrationCost)/10000
baseDeposit +
arbitrationCost +
(sharedStakeMultiplier * arbitrationCost) / 10000
)
})

Expand Down Expand Up @@ -168,7 +179,10 @@ contract('ArbitrableAddressList', function(accounts) {

await arbitrableAddressList.challengeRequest(submissionAddress, '', {
from: partyB,
value: challengeReward + arbitrationCost + (sharedStakeMultiplier * arbitrationCost) / 10000
value:
baseDeposit +
arbitrationCost +
(sharedStakeMultiplier * arbitrationCost) / 10000
})

const request = await arbitrableAddressList.getRequestInfo(
Expand All @@ -194,18 +208,10 @@ contract('ArbitrableAddressList', function(accounts) {
0
)

const sharedRequiredStake =
(sharedStakeMultiplier * arbitrationCost) / MULTIPLIER_DIVISOR

request = await arbitrableAddressList.getRequestInfo(
submissionAddress,
0
)
let round = await arbitrableAddressList.getRoundInfo(
submissionAddress,
0,
0
)

request = await arbitrableAddressList.getRequestInfo(
submissionAddress,
Expand Down Expand Up @@ -389,24 +395,27 @@ contract('ArbitrableAddressList', function(accounts) {
assert.equal(governorAfter, partyB, 'governor should be partyB')
})

it('should update challengeReward', async () => {
const challengeRewardBefore = await arbitrableAddressList.challengeReward()
const newChallengeReward = challengeRewardBefore.toNumber() + 1000
it('should update baseDeposit', async () => {
const baseDepositBefore = await arbitrableAddressList.requesterBaseDeposit()
const newChallengeReward = baseDepositBefore.toNumber() + 1000

await arbitrableAddressList.changeChallengeReward(newChallengeReward, {
from: governor
})
await arbitrableAddressList.changeRequesterBaseDeposit(
newChallengeReward,
{
from: governor
}
)

const challengeRewardAfter = await arbitrableAddressList.challengeReward()
const baseDepositAfter = await arbitrableAddressList.requesterBaseDeposit()
assert.notEqual(
challengeRewardAfter,
challengeRewardBefore,
'challengeReward should have changed'
baseDepositAfter,
baseDepositBefore,
'baseDeposit should have changed'
)
assert.equal(
challengeRewardAfter.toNumber(),
baseDepositAfter.toNumber(),
newChallengeReward,
'challengeReward should have changed'
'baseDeposit should have changed'
)
})

Expand Down Expand Up @@ -459,26 +468,26 @@ contract('ArbitrableAddressList', function(accounts) {
assert.notEqual(governorAfter, partyB, 'governor should not be partyB')
})

it('should not update challengeReward', async () => {
const challengeRewardBefore = await arbitrableAddressList.challengeReward()
const newChallengeReward = challengeRewardBefore.toNumber() + 1000
it('should not update baseDeposit', async () => {
const baseDepositBefore = await arbitrableAddressList.requesterBaseDeposit()
const newChallengeReward = baseDepositBefore.toNumber() + 1000

await expectThrow(
arbitrableAddressList.changeChallengeReward(newChallengeReward, {
arbitrableAddressList.changeRequesterBaseDeposit(newChallengeReward, {
from: partyB
})
)

const challengeRewardAfter = await arbitrableAddressList.challengeReward()
const baseDepositAfter = await arbitrableAddressList.requesterBaseDeposit()
assert.equal(
challengeRewardAfter.toNumber(),
challengeRewardBefore.toNumber(),
'challengeReward should not have changed'
baseDepositAfter.toNumber(),
baseDepositBefore.toNumber(),
'baseDeposit should not have changed'
)
assert.notEqual(
challengeRewardAfter.toNumber(),
baseDepositAfter.toNumber(),
newChallengeReward,
'challengeReward should not have changed'
'baseDeposit should not have changed'
)
})

Expand Down

0 comments on commit 76a2c10

Please sign in to comment.