diff --git a/default_settings.json b/default_settings.json index aeb457c18..00111b346 100644 --- a/default_settings.json +++ b/default_settings.json @@ -6,6 +6,7 @@ "slashingWindow": 10000, "uptimeWindow": 250, "initialPageSize": 30, + "validatorStatus0": 0, "bech32PrefixAccAddr": "cosmos", "bech32PrefixAccPub": "cosmospub", "bech32PrefixValAddr": "cosmosvaloper", diff --git a/imports/api/blocks/server/methods.js b/imports/api/blocks/server/methods.js index 5417058cd..896324810 100644 --- a/imports/api/blocks/server/methods.js +++ b/imports/api/blocks/server/methods.js @@ -375,7 +375,10 @@ Meteor.methods({ validator.profile_url = getValidatorProfileUrl(validatorData.description.identity) validator.operator_address = validatorData.operator_address; validator.delegator_address = Meteor.call('getDelegator', validatorData.operator_address); - validator.jailed = validatorData.jailed; + + // validatorData.jailed may be undefined in cosmos-sdk v0.39.0. + validator.jailed = !!validatorData.jailed; + validator.status = validatorData.status; validator.min_self_delegation = validatorData.min_self_delegation; validator.tokens = validatorData.tokens; @@ -521,7 +524,7 @@ Meteor.methods({ Object.keys(validatorSet).forEach((conPubKey) => { let validatorData = validatorSet[conPubKey]; // Active validators should have been updated in previous steps - if (validatorData.status === 2) + if (validatorData.status === 2 + Meteor.settings.public.validatorStatus0) return if (dbValidators[conPubKey] == undefined) { @@ -621,7 +624,7 @@ Meteor.methods({ if (height % 60 == 1){ console.log("===== calculate voting power distribution ====="); - let activeValidators = Validators.find({status:2,jailed:false},{sort:{voting_power:-1}}).fetch(); + let activeValidators = Validators.find({status:2 + Meteor.settings.public.validatorStatus0,jailed:false},{sort:{voting_power:-1}}).fetch(); let numTopTwenty = Math.ceil(activeValidators.length*0.2); let numBottomEighty = activeValidators.length - numTopTwenty; diff --git a/imports/api/chain/server/methods.js b/imports/api/chain/server/methods.js index 7cc8db9a8..dba3a45d5 100644 --- a/imports/api/chain/server/methods.js +++ b/imports/api/chain/server/methods.js @@ -239,7 +239,7 @@ Meteor.methods({ delegator_address: msg[m].value.delegator_address, voting_power: Math.floor(parseInt(msg[m].value.value.amount) / Coin.StakingCoin.fraction), jailed: false, - status: 2 + status: 2 + Meteor.settings.validatorStatus0 } totalVotingPower += validator.voting_power; diff --git a/imports/api/validators/server/publications.js b/imports/api/validators/server/publications.js index e3e1870fb..04f80fdbc 100644 --- a/imports/api/validators/server/publications.js +++ b/imports/api/validators/server/publications.js @@ -25,7 +25,7 @@ publishComposite('validators.firstSeen',{ Meteor.publish('validators.voting_power', function(){ return Validators.find({ - status: 2, + status: 2 + Meteor.settings.public.validatorStatus0, jailed:false },{ sort:{ diff --git a/imports/ui/components/AccountTooltip.jsx b/imports/ui/components/AccountTooltip.jsx index 6ef77a4da..18d7ba362 100644 --- a/imports/ui/components/AccountTooltip.jsx +++ b/imports/ui/components/AccountTooltip.jsx @@ -49,7 +49,7 @@ export default class AccountTooltip extends Account{ return let validator = this.state.validator; let moniker = validator.description && validator.description.moniker || validator.address; - let isActive = validator.status == 2 && !validator.jailed; + let isActive = validator.status == 2 + Meteor.settings.public.validatorStatus0 && !validator.jailed; return @@ -77,7 +77,7 @@ export default class AccountTooltip extends Account{ (validator.unbonding_time?:null)} :null} {(!isActive)? - {(validator.status == 0)?Unbonded:Unbonding} + {(validator.status == Meteor.settings.public.validatorStatus0)?Unbonded:Unbonding} {validator.jailed?Jailed:''} :null} {(isActive)? diff --git a/imports/ui/home/TopValidatorsContainer.js b/imports/ui/home/TopValidatorsContainer.js index 6808254f6..c227edb8a 100644 --- a/imports/ui/home/TopValidatorsContainer.js +++ b/imports/ui/home/TopValidatorsContainer.js @@ -21,7 +21,7 @@ export default TopValidatorsContainer = withTracker(() => { if (Meteor.isServer || !loading){ status = Chain.findOne({chainId:Meteor.settings.public.chainId}); - validators = Validators.find({status: 2, jailed:false}).fetch(); + validators = Validators.find({status: 2 + Meteor.settings.public.validatorStatus0, jailed:false}).fetch(); if (Meteor.isServer){ // loading = false; diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 3275190e3..3d0efb56e 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -119,7 +119,7 @@ return { - return !validator.jailed && validator.status == 2; + return !validator.jailed && validator.status == 2 + Meteor.settings.public.validatorStatus0; } const isBetween = (value, min, max) => { @@ -511,7 +511,7 @@ class LedgerButton extends Component { getValidatorOptions = () => { let activeValidators = Validators.find( - {"jailed": false, "status": 2}, + {"jailed": false, "status": 2 + Meteor.settings.public.validatorStatus0}, {"sort":{"description.moniker":1}} ); let redelegations = this.state.redelegations || {}; diff --git a/imports/ui/validators/List.jsx b/imports/ui/validators/List.jsx index d254ad56b..bffe7a07b 100644 --- a/imports/ui/validators/List.jsx +++ b/imports/ui/validators/List.jsx @@ -19,7 +19,7 @@ const ValidatorRow = (props) => { {(!props.inactive)?call_split {props.validator.commission.commission_rates?numbro(props.validator.commission.commission_rates.rate).format('0.00%'):''}:''} {(!props.inactive)?{props.validator.uptime?props.validator.uptime.toFixed(2):0}% :''} {(props.inactive)?{props.validator.lastSeen?:''}:''} - {(props.inactive)?{(props.validator.status == 0)?Unbonded:Unbonding}:''} + {(props.inactive)?{(props.validator.status == Meteor.settings.public.validatorStatus0)?Unbonded:Unbonding}:''} {(props.inactive)?{props.validator.jailed?Jailed:''}:''} diff --git a/imports/ui/validators/ListContainer.js b/imports/ui/validators/ListContainer.js index 31f06b2ed..7c32b8376 100644 --- a/imports/ui/validators/ListContainer.js +++ b/imports/ui/validators/ListContainer.js @@ -19,7 +19,7 @@ export default ValidatorListContainer = withTracker((props) => { if (props.inactive){ validatorsCond = { $or: [ - { status: { $lt : 3 } }, + { status: { $lt : 2 + Meteor.settings.public.validatorStatus0 } }, { jailed: true } ] } @@ -27,7 +27,7 @@ export default ValidatorListContainer = withTracker((props) => { else{ validatorsCond = { jailed: false, - status: 3 + status: 2 + Meteor.settings.public.validatorStatus0 } }