mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add ConsensusCritical to proposal validators
Changing validation rules can potentially break consensus (e.g. a past proposal has been accepted according to old rules, and might become invalid by new rules. The result of the proposal would become invalidated then.
This commit is contained in:
parent
13ca802dd1
commit
fb3ca06600
8 changed files with 39 additions and 8 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.state.DaoStateService;
|
||||
import bisq.core.dao.state.model.blockchain.BaseTx;
|
||||
|
@ -33,8 +34,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import static org.apache.commons.lang3.Validate.notEmpty;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class ProposalValidator {
|
||||
public abstract class ProposalValidator implements ConsensusCritical {
|
||||
protected final DaoStateService daoStateService;
|
||||
protected final PeriodService periodService;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.compensation;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -33,8 +34,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.apache.commons.lang3.Validate.notEmpty;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class CompensationValidator extends ProposalValidator {
|
||||
public class CompensationValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public CompensationValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.confiscatebond;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -30,8 +31,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import static org.apache.commons.lang3.Validate.notEmpty;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class ConfiscateBondValidator extends ProposalValidator {
|
||||
public class ConfiscateBondValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public ConfiscateBondValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.generic;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -27,8 +28,11 @@ import javax.inject.Inject;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class GenericProposalValidator extends ProposalValidator {
|
||||
public class GenericProposalValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public GenericProposalValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.core.dao.governance.proposal.param;
|
|||
|
||||
import bisq.core.app.BisqEnvironment;
|
||||
import bisq.core.btc.wallet.Restrictions;
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.param.Param;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
|
@ -45,11 +46,13 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
//TODO Use translation properties in error messages a they are shown to user.
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*
|
||||
* We do not store the values as domain types (Coin, int, String) but all as Strings. So we need to parse it to the
|
||||
* expected data type even if we get the data not from user input.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ChangeParamValidator extends ProposalValidator {
|
||||
public class ChangeParamValidator extends ProposalValidator implements ConsensusCritical {
|
||||
public enum Result {
|
||||
OK,
|
||||
SAME("New parameter value must be different to current value."),
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.reimbursement;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -34,8 +35,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.apache.commons.lang3.Validate.notEmpty;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class ReimbursementValidator extends ProposalValidator {
|
||||
public class ReimbursementValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public ReimbursementValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.removeAsset;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -30,8 +31,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import static org.apache.commons.lang3.Validate.notEmpty;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class RemoveAssetValidator extends ProposalValidator {
|
||||
public class RemoveAssetValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public RemoveAssetValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.core.dao.governance.proposal.role;
|
||||
|
||||
import bisq.core.dao.governance.ConsensusCritical;
|
||||
import bisq.core.dao.governance.period.PeriodService;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.dao.governance.proposal.ProposalValidator;
|
||||
|
@ -30,8 +31,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import static org.apache.commons.lang3.Validate.notNull;
|
||||
|
||||
/**
|
||||
* Changes here can potentially break consensus!
|
||||
*/
|
||||
@Slf4j
|
||||
public class RoleValidator extends ProposalValidator {
|
||||
public class RoleValidator extends ProposalValidator implements ConsensusCritical {
|
||||
|
||||
@Inject
|
||||
public RoleValidator(DaoStateService daoStateService, PeriodService periodService) {
|
||||
|
|
Loading…
Add table
Reference in a new issue