Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dao ui improvements #1751

Merged
merged 31 commits into from Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6299411
Fix/add comments
ManfredKarrer Oct 4, 2018
93b38d2
Add ButtonCell and PromptText to ComboBox in FormBuilder
ManfredKarrer Oct 4, 2018
5f43bea
Improve setFitToRowsForTableView method
ManfredKarrer Oct 5, 2018
ccdac8e
Add new items to Param
ManfredKarrer Oct 5, 2018
072cedc
Improve param change selection (WIP)
ManfredKarrer Oct 5, 2018
3e7eba8
Add Generic- and removeAsset proposals
ManfredKarrer Oct 5, 2018
4770ac9
Remove asset from comboBoxes if it was removed by voting
ManfredKarrer Oct 5, 2018
f4cfeef
Add checkTradeActivity method, remove ConvertToTradeStatistics2
ManfredKarrer Oct 5, 2018
6bcbfe7
Merge branch 'master' into Dao-UI-improvements
ManfredKarrer Oct 5, 2018
5dfbb6d
Merge branch 'master' into Dao-UI-improvements
ManfredKarrer Oct 7, 2018
57355f2
Merge branch 'Dao-UI-improvements'
ManfredKarrer Oct 8, 2018
d279dae
Rename chainHeadHeight to chainHeight
ManfredKarrer Oct 8, 2018
4cc17fe
Persist EvaluatedProposalList
ManfredKarrer Oct 9, 2018
58e6db0
Persist DecryptedBallotsWithMeritsList
ManfredKarrer Oct 9, 2018
5141806
Add handling for missing blindVote data
ManfredKarrer Oct 10, 2018
9b40306
Add handling for missing proposal data
ManfredKarrer Oct 10, 2018
db3cd32
Add VoteResultExceptionHandler
ManfredKarrer Oct 10, 2018
a63d1cc
Merge remote-tracking branch 'upstream/master'
ManfredKarrer Oct 10, 2018
d2c9843
Merge branch 'master' into Dao-UI-improvements
ManfredKarrer Oct 10, 2018
e99d733
Remove PHASE_BREAK4, adjust phase periods and fees
ManfredKarrer Oct 10, 2018
280af36
Reduce default btc miner fee from 200 to 50 sat/byte
ManfredKarrer Oct 10, 2018
c8f0098
Add comments, cleanups
ManfredKarrer Oct 10, 2018
923aaf6
Remove other base currencies from FeeService
ManfredKarrer Oct 10, 2018
8e22916
Adjust comments
ManfredKarrer Oct 10, 2018
965d741
Rename fields and params
ManfredKarrer Oct 10, 2018
4b9073c
Rename support for other base currencies in getDefaultMinFeePerByte
ManfredKarrer Oct 10, 2018
048767a
Make ProposalConsensus and CompensationConsensus methods static
ManfredKarrer Oct 10, 2018
aeebae9
Support trade fees defined DAO params
ManfredKarrer Oct 10, 2018
c3f508e
Adjust DAO params
ManfredKarrer Oct 10, 2018
62a8246
Update comments
ManfredKarrer Oct 10, 2018
5879dd9
Change log level for printing asset trade stats
ManfredKarrer Oct 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions common/src/main/proto/pb.proto
Expand Up @@ -932,6 +932,8 @@ message PersistableEnvelope {
MeritList merit_list = 23;
BondedRoleList bonded_role_list = 24;
RemovedAssetList removed_asset_list = 25;
EvaluatedProposalList evaluated_proposal_list = 26;
DecryptedBallotsWithMeritsList decrypted_ballots_with_merits_list = 27;
}
}

Expand Down Expand Up @@ -1625,6 +1627,39 @@ message MeritList {
repeated Merit merit = 1;
}

message ProposalVoteResult {
Proposal proposal = 1;
int64 stake_of_Accepted_votes = 2;
int64 stake_of_Rejected_votes = 3;
int32 num_accepted_votes = 4;
int32 num_rejected_votes = 5;
int32 num_ignored_votes = 6;
}

message EvaluatedProposal {
bool is_accepted = 1;
ProposalVoteResult proposal_vote_result = 2;
int64 required_quorum = 3;
int64 required_threshold = 4;
}

message EvaluatedProposalList {
repeated EvaluatedProposal evaluated_proposal = 1;
}

message DecryptedBallotsWithMerits {
bytes hash_of_blind_vote_list = 1;
string vote_reveal_tx_id = 2;
string blind_vote_tx_id = 3;
int64 stake = 4;
BallotList ballot_list = 5;
MeritList merit_list = 6;
}

message DecryptedBallotsWithMeritsList {
repeated DecryptedBallotsWithMerits decrypted_ballots_with_merits = 1;
}

///////////////////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Expand Up @@ -23,6 +23,7 @@
import bisq.core.dao.governance.blindvote.MyBlindVoteListService;
import bisq.core.dao.governance.myvote.MyVoteListService;
import bisq.core.dao.governance.role.BondedRolesService;
import bisq.core.dao.governance.voteresult.VoteResultService;
import bisq.core.filter.FilterManager;
import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.trade.statistics.TradeStatisticsManager;
Expand Down Expand Up @@ -52,7 +53,8 @@ public AppSetupWithP2PAndDAO(EncryptionService encryptionService,
BallotListService ballotListService,
MyBlindVoteListService myBlindVoteListService,
BondedRolesService bondedRolesService,
AssetService assetService) {
AssetService assetService,
VoteResultService voteResultService) {
super(encryptionService,
keyRing,
p2PService,
Expand All @@ -67,6 +69,7 @@ public AppSetupWithP2PAndDAO(EncryptionService encryptionService,
persistedDataHosts.add(myBlindVoteListService);
persistedDataHosts.add(bondedRolesService);
persistedDataHosts.add(assetService);
persistedDataHosts.add(voteResultService);
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/bisq/core/dao/DaoFacade.java
Expand Up @@ -490,16 +490,16 @@ public boolean isInPhaseButNotLastBlock(DaoPhase.Phase phase) {
return periodService.isInPhaseButNotLastBlock(phase);
}

public boolean isTxInCorrectCycle(int txHeight, int chainHeadHeight) {
return periodService.isTxInCorrectCycle(txHeight, chainHeadHeight);
public boolean isTxInCorrectCycle(int txHeight, int chainHeight) {
return periodService.isTxInCorrectCycle(txHeight, chainHeight);
}

public boolean isTxInCorrectCycle(String txId, int chainHeadHeight) {
return periodService.isTxInCorrectCycle(txId, chainHeadHeight);
public boolean isTxInCorrectCycle(String txId, int chainHeight) {
return periodService.isTxInCorrectCycle(txId, chainHeight);
}

public boolean isTxInPhaseAndCycle(String txId, DaoPhase.Phase phase, int chainHeadHeight) {
return periodService.isTxInPhaseAndCycle(txId, phase, chainHeadHeight);
public boolean isTxInPhaseAndCycle(String txId, DaoPhase.Phase phase, int chainHeight) {
return periodService.isTxInPhaseAndCycle(txId, phase, chainHeight);
}

public boolean isUnspent(TxOutputKey key) {
Expand Down
Expand Up @@ -115,8 +115,8 @@ public static byte[] getOpReturnData(byte[] hash) throws IOException {
}
}

public static Coin getFee(BsqStateService bsqStateService, int chainHeadHeight) {
Coin fee = Coin.valueOf(bsqStateService.getParamValue(Param.BLIND_VOTE_FEE, chainHeadHeight));
public static Coin getFee(BsqStateService bsqStateService, int chainHeight) {
Coin fee = Coin.valueOf(bsqStateService.getParamValue(Param.BLIND_VOTE_FEE, chainHeight));
log.info("Fee for blind vote: " + fee);
return fee;
}
Expand Down
Expand Up @@ -50,7 +50,7 @@ public PB.MeritList toProtoMessage() {
return getBuilder().build();
}

private PB.MeritList.Builder getBuilder() {
public PB.MeritList.Builder getBuilder() {
return PB.MeritList.newBuilder()
.addAllMerit(getList().stream()
.map(Merit::toProtoMessage)
Expand Down
Expand Up @@ -34,8 +34,8 @@
*/
@Slf4j
public class ProposalConsensus {
public Coin getFee(BsqStateService bsqStateService, int chainHeadHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.PROPOSAL_FEE, chainHeadHeight));
public Coin getFee(BsqStateService bsqStateService, int chainHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.PROPOSAL_FEE, chainHeight));
}

public byte[] getHashOfPayload(Proposal payload) {
Expand Down
Expand Up @@ -27,12 +27,12 @@

@Slf4j
public class CompensationConsensus extends ProposalConsensus {
public static Coin getMinCompensationRequestAmount(BsqStateService bsqStateService, int chainHeadHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.COMPENSATION_REQUEST_MIN_AMOUNT, chainHeadHeight));
public static Coin getMinCompensationRequestAmount(BsqStateService bsqStateService, int chainHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.COMPENSATION_REQUEST_MIN_AMOUNT, chainHeight));
}

public static Coin getMaxCompensationRequestAmount(BsqStateService bsqStateService, int chainHeadHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.COMPENSATION_REQUEST_MAX_AMOUNT, chainHeadHeight));
public static Coin getMaxCompensationRequestAmount(BsqStateService bsqStateService, int chainHeight) {
return Coin.valueOf(bsqStateService.getParamValue(Param.COMPENSATION_REQUEST_MAX_AMOUNT, chainHeight));
}

}
Expand Up @@ -24,8 +24,13 @@
import bisq.core.dao.governance.merit.MeritList;
import bisq.core.dao.state.BsqStateService;

import bisq.common.proto.persistable.PersistablePayload;
import bisq.common.util.Utilities;

import io.bisq.generated.protobuffer.PB;

import com.google.protobuf.ByteString;

import java.util.Optional;

import lombok.Value;
Expand All @@ -36,7 +41,7 @@
*/
@Slf4j
@Value
public class DecryptedBallotsWithMerits {
public class DecryptedBallotsWithMerits implements PersistablePayload {
private final byte[] hashOfBlindVoteList;
private final String voteRevealTxId; // not used yet but keep it for now
private final String blindVoteTxId; // not used yet but keep it for now
Expand All @@ -54,6 +59,37 @@ public class DecryptedBallotsWithMerits {
this.meritList = meritList;
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public PB.DecryptedBallotsWithMerits toProtoMessage() {
PB.DecryptedBallotsWithMerits.Builder builder = PB.DecryptedBallotsWithMerits.newBuilder()
.setHashOfBlindVoteList(ByteString.copyFrom(hashOfBlindVoteList))
.setVoteRevealTxId(voteRevealTxId)
.setBlindVoteTxId(blindVoteTxId)
.setStake(stake)
.setBallotList(ballotList.getBuilder())
.setMeritList(meritList.getBuilder());
return builder.build();
}

public static DecryptedBallotsWithMerits fromProto(PB.DecryptedBallotsWithMerits proto) {
return new DecryptedBallotsWithMerits(proto.getHashOfBlindVoteList().toByteArray(),
proto.getVoteRevealTxId(),
proto.getBlindVoteTxId(),
proto.getStake(),
BallotList.fromProto(proto.getBallotList()),
MeritList.fromProto(proto.getMeritList()));
}


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////

public Optional<Vote> getVote(String proposalTxId) {
return ballotList.stream()
.filter(ballot -> ballot.getTxId().equals(proposalTxId))
Expand Down
@@ -0,0 +1,76 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.dao.governance.voteresult;

import bisq.core.dao.governance.ConsensusCritical;

import bisq.common.proto.persistable.PersistableList;

import io.bisq.generated.protobuffer.PB;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import lombok.EqualsAndHashCode;

/**
* PersistableEnvelope wrapper for list of decryptedBallotsWithMerits.
*/
@EqualsAndHashCode(callSuper = true)
public class DecryptedBallotsWithMeritsList extends PersistableList<DecryptedBallotsWithMerits> implements ConsensusCritical {

public DecryptedBallotsWithMeritsList(List<DecryptedBallotsWithMerits> list) {
super(list);
}

public DecryptedBallotsWithMeritsList() {
super();
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public PB.PersistableEnvelope toProtoMessage() {
return PB.PersistableEnvelope.newBuilder().setDecryptedBallotsWithMeritsList(getBuilder()).build();
}

private PB.DecryptedBallotsWithMeritsList.Builder getBuilder() {
return PB.DecryptedBallotsWithMeritsList.newBuilder()
.addAllDecryptedBallotsWithMerits(getList().stream()
.map(DecryptedBallotsWithMerits::toProtoMessage)
.collect(Collectors.toList()));
}

public static DecryptedBallotsWithMeritsList fromProto(PB.DecryptedBallotsWithMeritsList proto) {
return new DecryptedBallotsWithMeritsList(new ArrayList<>(proto.getDecryptedBallotsWithMeritsList().stream()
.map(DecryptedBallotsWithMerits::fromProto)
.collect(Collectors.toList())));
}

@Override
public String toString() {
return "List of blindVoteTxId's in DecryptedBallotsWithMeritsList: " + getList().stream()
.map(DecryptedBallotsWithMerits::getBlindVoteTxId)
.collect(Collectors.toList());
}
}

Expand Up @@ -19,10 +19,14 @@

import bisq.core.dao.governance.proposal.Proposal;

import bisq.common.proto.persistable.PersistablePayload;

import io.bisq.generated.protobuffer.PB;

import lombok.Value;

@Value
public class EvaluatedProposal {
public class EvaluatedProposal implements PersistablePayload {
private final boolean isAccepted;
private final ProposalVoteResult proposalVoteResult;
private final long requiredQuorum;
Expand All @@ -35,6 +39,33 @@ public class EvaluatedProposal {
this.requiredThreshold = requiredThreshold;
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public PB.EvaluatedProposal toProtoMessage() {
PB.EvaluatedProposal.Builder builder = PB.EvaluatedProposal.newBuilder()
.setIsAccepted(isAccepted)
.setProposalVoteResult(proposalVoteResult.toProtoMessage())
.setRequiredQuorum(requiredQuorum)
.setRequiredThreshold(requiredThreshold);
return builder.build();
}

public static EvaluatedProposal fromProto(PB.EvaluatedProposal proto) {
return new EvaluatedProposal(proto.getIsAccepted(),
ProposalVoteResult.fromProto(proto.getProposalVoteResult()),
proto.getRequiredQuorum(),
proto.getRequiredThreshold());
}


///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////

public Proposal getProposal() {
return proposalVoteResult.getProposal();
}
Expand Down