Skip to content

Commit c3751f7

Browse files
authored
remove reputation flow from genesis protocol (#97)
* deprecte reputation flow * remove burm and mint rep from vm * add back ReddemReputation event
1 parent b4fd560 commit c3751f7

File tree

6 files changed

+46
-222
lines changed

6 files changed

+46
-222
lines changed

contracts/test/AbsoluteVoteExecuteMock.sol

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@ contract AbsoluteVoteExecuteMock is Debug, VotingMachineCallbacksInterface,
2424
bytes32 _paramsHash
2525
);
2626

27-
function mintReputation(uint256 _amount, address _beneficiary, bytes32)
28-
external
29-
onlyOwner
30-
override
31-
returns(bool)
32-
{
33-
return reputation.mint(_beneficiary, _amount);
34-
}
35-
36-
function burnReputation(uint256 _amount, address _beneficiary, bytes32)
37-
external
38-
onlyOwner
39-
override
40-
returns(bool)
41-
{
42-
return reputation.burn(_beneficiary, _amount);
43-
}
44-
4527
function stakingTokenTransfer(IERC20 _stakingToken, address _beneficiary, uint256 _amount, bytes32)
4628
external
4729
onlyOwner

contracts/test/GenesisProtocolCallbacksMock.sol

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,6 @@ contract GenesisProtocolCallbacksMock is Debug, VotingMachineCallbacksInterface,
2525
bytes32 _paramsHash
2626
);
2727

28-
function mintReputation(uint256 _amount, address _beneficiary, bytes32)
29-
external
30-
onlyOwner
31-
override
32-
returns(bool)
33-
{
34-
return reputation.mint(_beneficiary, _amount);
35-
}
36-
37-
function burnReputation(uint256 _amount, address _beneficiary, bytes32)
38-
external
39-
onlyOwner
40-
override
41-
returns(bool)
42-
{
43-
return reputation.burn(_beneficiary, _amount);
44-
}
45-
4628
function stakingTokenTransfer(IERC20 _stakingToken, address _beneficiary, uint256 _amount, bytes32)
4729
external
4830
onlyOwner

contracts/votingMachines/GenesisProtocol.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "./GenesisProtocolLogic.sol";
88

99
/**
1010
* @title GenesisProtocol implementation -an organization's voting machine scheme.
11+
* Note : Reputation flow is deprected
1112
*/
1213
contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
1314
using ECDSA for bytes32;
@@ -224,15 +225,15 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
224225
/**
225226
* @dev proposalStatus return the total votes and stakes for a given proposal
226227
* @param _proposalId the ID of the proposal
227-
* @return uint256 preBoostedVotes YES
228-
* @return uint256 preBoostedVotes NO
228+
* @return uint256 votes YES
229+
* @return uint256 votes NO
229230
* @return uint256 total stakes YES
230231
* @return uint256 total stakes NO
231232
*/
232233
function proposalStatus(bytes32 _proposalId) external view returns(uint256, uint256, uint256, uint256) {
233234
return (
234-
proposals[_proposalId].preBoostedVotes[YES],
235-
proposals[_proposalId].preBoostedVotes[NO],
235+
proposals[_proposalId].votes[YES],
236+
proposals[_proposalId].votes[NO],
236237
proposals[_proposalId].stakes[YES],
237238
proposals[_proposalId].stakes[NO]
238239
);

contracts/votingMachines/GenesisProtocolLogic.sol

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
3636
uint256 limitExponentValue;// an upper limit for numberOfBoostedProposals
3737
//in the threshold calculation to prevent overflow
3838
uint256 quietEndingPeriod; //quite ending period
39-
uint256 proposingRepReward;//proposer reputation reward.
40-
uint256 votersReputationLossRatio;//Unsuccessful pre booster
41-
//voters lose votersReputationLossRatio% of their reputation.
39+
uint256 proposingRepReward;//deprecated
40+
uint256 votersReputationLossRatio;//deprecated
4241
uint256 minimumDaoBounty;
4342
uint256 daoBountyConst;//The DAO downstake for each proposal is calculate according to the formula
4443
//(daoBountyConst * averageBoostDownstakes)/100 .
@@ -65,7 +64,7 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
6564
address callbacks; // should fulfill voting callbacks interface.
6665
ProposalState state;
6766
uint256 winningVote; //the winning vote.
68-
address proposer;
67+
address proposer; //deprecated - will not be set
6968
//the proposal boosted period limit . it is updated for the case of quiteWindow mode.
7069
uint256 currentBoostedVotePeriodLimit;
7170
bytes32 paramsHash;
@@ -80,8 +79,6 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
8079
bool daoRedeemItsWinnings;
8180
// vote reputation
8281
mapping(uint256 => uint256 ) votes;
83-
// vote reputation
84-
mapping(uint256 => uint256 ) preBoostedVotes;
8582
// a mapping between address and voterBitmap
8683
// voterBitmap : bits 0-127 the voter reputation.
8784
// bits 247 indicate if the vote was during regular or preBoosted state.
@@ -112,10 +109,11 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
112109
uint256 _amount
113110
);
114111

112+
//this event definition is here to maintain subgraph competability
115113
event RedeemReputation(bytes32 indexed _proposalId,
116-
address indexed _organization,
117-
address indexed _beneficiary,
118-
uint256 _amount
114+
address indexed _organization,
115+
address indexed _beneficiary,
116+
uint256 _amount
119117
);
120118

121119
event StateChange(bytes32 indexed _proposalId, ProposalState _proposalState);
@@ -192,8 +190,8 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
192190
* state (stable) before boosted.
193191
* _params[4] -_thresholdConst
194192
* _params[5] -_quietEndingPeriod
195-
* _params[6] -_proposingRepReward
196-
* _params[7] -_votersReputationLossRatio
193+
* _params[6] - deprected - set to 0
194+
* _params[7] -deprected - set to 0
197195
* _params[8] -_minimumDaoBounty
198196
* _params[9] -_daoBountyConst
199197
* _params[10] -_activationTime
@@ -208,7 +206,6 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
208206
{
209207
require(_params[0] <= 100 && _params[0] >= 50, "50 <= queuedVoteRequiredPercentage <= 100");
210208
require(_params[4] <= 16000 && _params[4] > 1000, "1000 < thresholdConst <= 16000");
211-
require(_params[7] <= 100, "votersReputationLossRatio <= 100");
212209
require(_params[2] >= _params[5], "boostedVotePeriodLimit >= quietEndingPeriod");
213210
require(_params[8] > 0, "minimumDaoBounty should be > 0");
214211
require(_params[9] > 0, "daoBountyConst should be > 0");
@@ -233,8 +230,8 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
233230
thresholdConst:uint216(_params[4]).fraction(uint216(1000)),
234231
limitExponentValue:limitExponent,
235232
quietEndingPeriod: _params[5],
236-
proposingRepReward: _params[6],
237-
votersReputationLossRatio:_params[7],
233+
proposingRepReward: 0,
234+
votersReputationLossRatio: 0,
238235
minimumDaoBounty:_params[8],
239236
daoBountyConst:_params[9],
240237
activationTime:_params[10],
@@ -254,12 +251,11 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
254251
* [1] voterReputationReward
255252
* [2] proposerReputationReward
256253
*/
257-
// solhint-disable-next-line function-max-lines,code-complexity
254+
// solhint-disable-next-line code-complexity
258255
function redeem(bytes32 _proposalId, address _beneficiary) public returns (uint[3] memory rewards) {
259256
Proposal storage proposal = proposals[_proposalId];
260257
require((proposal.state == ProposalState.Executed)||(proposal.state == ProposalState.ExpiredInQueue),
261258
"Proposal should be Executed or ExpiredInQueue");
262-
Parameters memory params = parameters[proposal.paramsHash];
263259
//as staker
264260
Staker storage staker = proposal.stakers[_beneficiary];
265261
uint256 totalWinningStakes = proposal.stakes[proposal.winningVote];
@@ -292,49 +288,11 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
292288
.sub(proposal.daoBounty);
293289
proposal.daoRedeemItsWinnings = true;
294290
}
295-
296-
//as voter
297-
uint256 voter = proposal.voters[_beneficiary];
298-
uint256 voterReputation = uint256(uint128(voter));
299-
bool voterPreBoosted = (voter >> PREBOOSTED_BIT_INDEX & 1 == 1);
300-
uint8 voterVote = uint8(voter >> VOTE_BIT_INDEX);
301-
if ((voterReputation != 0) && (voterPreBoosted)) {
302-
if (proposal.state == ProposalState.ExpiredInQueue) {
303-
//give back reputation for the voter
304-
rewards[1] = ((voterReputation.mul(params.votersReputationLossRatio))/100);
305-
} else if (proposal.winningVote == voterVote) {
306-
uint256 lostReputation;
307-
if (proposal.winningVote == YES) {
308-
lostReputation = proposal.preBoostedVotes[NO];
309-
} else {
310-
lostReputation = proposal.preBoostedVotes[YES];
311-
}
312-
lostReputation = (lostReputation.mul(params.votersReputationLossRatio))/100;
313-
rewards[1] = ((voterReputation.mul(params.votersReputationLossRatio))/100)
314-
.add((voterReputation.mul(lostReputation))/proposal.preBoostedVotes[proposal.winningVote]);
315-
}
316-
proposal.voters[_beneficiary] = 0;
317-
}
318-
//as proposer
319-
if ((proposal.proposer == _beneficiary)&&(proposal.winningVote == YES)&&(proposal.proposer != address(0))) {
320-
rewards[2] = params.proposingRepReward;
321-
proposal.proposer = address(0);
322-
}
323291
if (rewards[0] != 0) {
324292
proposal.totalStakes = proposal.totalStakes.sub(rewards[0]);
325293
require(stakingToken.transfer(_beneficiary, rewards[0]), "transfer to beneficiary failed");
326294
emit Redeem(_proposalId, organizations[proposal.organizationId], _beneficiary, rewards[0]);
327295
}
328-
if (rewards[1].add(rewards[2]) != 0) {
329-
VotingMachineCallbacksInterface(proposal.callbacks)
330-
.mintReputation(rewards[1].add(rewards[2]), _beneficiary, _proposalId);
331-
emit RedeemReputation(
332-
_proposalId,
333-
organizations[proposal.organizationId],
334-
_beneficiary,
335-
rewards[1].add(rewards[2])
336-
);
337-
}
338296
}
339297

340298
/**
@@ -438,8 +396,8 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
438396
_params[3],
439397
_params[4],
440398
_params[5],
441-
_params[6],
442-
_params[7],
399+
uint256(0),
400+
uint256(0),
443401
_params[8],
444402
_params[9],
445403
_params[10])
@@ -649,7 +607,6 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
649607
// solhint-disable-next-line not-rely-on-time
650608
proposal.times[0] = now;//submitted time
651609
proposal.currentBoostedVotePeriodLimit = parameters[_paramsHash].boostedVotePeriodLimit;
652-
proposal.proposer = _proposer;
653610
proposal.winningVote = NO;
654611
proposal.paramsHash = _paramsHash;
655612
if (organizations[proposal.organizationId] == address(0)) {
@@ -730,11 +687,6 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
730687
voter = voter | PREBOOSTED_BIT_SET;
731688
}
732689
proposal.voters[_voter] = voter;
733-
if ((proposal.state == ProposalState.PreBoosted) || (proposal.state == ProposalState.Queued)) {
734-
proposal.preBoostedVotes[_vote] = rep.add(proposal.preBoostedVotes[_vote]);
735-
uint256 reputationDeposit = (params.votersReputationLossRatio.mul(rep))/100;
736-
VotingMachineCallbacksInterface(proposal.callbacks).burnReputation(reputationDeposit, _voter, _proposalId);
737-
}
738690
emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, rep);
739691
return _execute(_proposalId);
740692
}

contracts/votingMachines/VotingMachineCallbacksInterface.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ pragma solidity 0.6.12;
33

44
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
55

6-
interface VotingMachineCallbacksInterface {
7-
function mintReputation(uint256 _amount, address _beneficiary, bytes32 _proposalId) external returns(bool);
8-
function burnReputation(uint256 _amount, address _owner, bytes32 _proposalId) external returns(bool);
96

7+
interface VotingMachineCallbacksInterface {
108
function stakingTokenTransfer(IERC20 _stakingToken, address _beneficiary, uint256 _amount, bytes32 _proposalId)
119
external
1210
returns(bool);

0 commit comments

Comments
 (0)