From fc362c71be4a0567d7b1d976049d46f366c2447f Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 5 Feb 2019 21:16:16 +0100 Subject: [PATCH 1/2] Fix missing removal of old or invalid proposals - If a proposal had a tx which is not in our BSQ state it was not removed - If a tx was outdated (> 60 days old) it was only removed if we are in proposal phase. We added check for past cycle to cover those as well. --- .../governance/proposal/ProposalService.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/governance/proposal/ProposalService.java b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalService.java index d215c8d16f5..e20dec63fe7 100644 --- a/core/src/main/java/bisq/core/dao/governance/proposal/ProposalService.java +++ b/core/src/main/java/bisq/core/dao/governance/proposal/ProposalService.java @@ -239,18 +239,23 @@ private void onProtectedDataRemoved(ProtectedStorageEntry entry) { if (protectedStoragePayload instanceof TempProposalPayload) { Proposal proposal = ((TempProposalPayload) protectedStoragePayload).getProposal(); // We allow removal only if we are in the proposal phase. - if (periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL)) { + boolean inPhase = periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL); + boolean txInPastCycle = periodService.isTxInPastCycle(proposal.getTxId(), daoStateService.getChainHeight()); + Optional tx = daoStateService.getTx(proposal.getTxId()); + boolean unconfirmedOrNonBsqTx = !tx.isPresent(); + // if the tx is unconfirmed we need to be in the PROPOSAL phase, otherwise the tx must be confirmed. + if (inPhase || txInPastCycle || unconfirmedOrNonBsqTx) { if (tempProposals.contains(proposal)) { - log.info("We received a remove request for a TempProposalPayload and have removed the proposal " + - "from our list. proposalTxId={}", proposal.getTxId()); tempProposals.remove(proposal); + log.info("We received a remove request for a TempProposalPayload and have removed the proposal " + + "from our list. proposal creation date={}, proposalTxId={}, inPhase={}, " + + "txInPastCycle={}, unconfirmedOrNonBsqTx={}", + proposal.getCreationDate(), proposal.getTxId(), inPhase, txInPastCycle, unconfirmedOrNonBsqTx); } } else { - Optional tx = daoStateService.getTx(proposal.getTxId()); log.warn("We received a remove request outside the PROPOSAL phase. " + - "Proposal.txId={}, current blockHeight={}, tx blockHeight={}, proposal creation date={}", - proposal.getTxId(), daoStateService.getChainHeight(), - tx.isPresent() ? tx.get().getBlockHeight() : "null", proposal.getCreationDate()); + "Proposal creation date={}, proposal.txId={}, current blockHeight={}", + proposal.getCreationDate(), proposal.getTxId(), daoStateService.getChainHeight()); } } } From df0a8b7571d8395a69e55d864a01cc07cd4a571a Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 5 Feb 2019 22:51:32 +0100 Subject: [PATCH 2/2] Remove duplicate log --- .../bisq/core/dao/governance/votereveal/VoteRevealService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java b/core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java index fd16b898598..860d93d4354 100644 --- a/core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java +++ b/core/src/main/java/bisq/core/dao/governance/votereveal/VoteRevealService.java @@ -242,7 +242,6 @@ private void revealVote(MyVote myVote, boolean inBlindVotePhase) { // If we are not in the right phase we just add an empty hash (still need to have the hash as otherwise we // would not recognize the tx as vote reveal tx) byte[] hashOfBlindVoteList = inBlindVotePhase ? getHashOfBlindVoteList() : new byte[20]; - log.info("revealVote: Sha256Ripemd160 hash of hashOfBlindVoteList " + Utilities.bytesAsHexString(hashOfBlindVoteList)); byte[] opReturnData = VoteRevealConsensus.getOpReturnData(hashOfBlindVoteList, myVote.getSecretKey()); // We search for my unspent stake output.