Skip to content

Commit

Permalink
number of seats changed to 1 in PV 49+ (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Dec 9, 2021
1 parent 00a0bf1 commit b9d499f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions utils/validators-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function showValidatorsTable(near, blockNumberOrHash) {
validatorsTable.addRow(
validator.account_id,
utils.format.formatNearAmount(validator.stake, 0),
new BN(validator.stake).div(seatPrice),
getNumberOfSeats(result.protocolConfig.protocol_version, validator.stake, seatPrice),
`${Math.floor(validator.num_produced_blocks / validator.num_expected_blocks * 10000) / 100}%`,
validator.num_produced_blocks,
validator.num_expected_blocks);
Expand All @@ -55,12 +55,12 @@ async function showNextValidatorsTable(near) {
'New',
validator.account_id,
utils.format.formatNearAmount(validator.stake, 0),
new BN(validator.stake).div(nextSeatPrice)));
getNumberOfSeats(result.protocolConfig.protocol_version, validator.stake, nextSeatPrice)));
diff.changedValidators.forEach((changeValidator) => nextValidatorsTable.addRow(
'Rewarded',
changeValidator.next.account_id,
`${utils.format.formatNearAmount(changeValidator.current.stake, 0)} -> ${utils.format.formatNearAmount(changeValidator.next.stake, 0)}`,
new BN(changeValidator.next.stake).div(nextSeatPrice)));
getNumberOfSeats(result.protocolConfig.protocol_version, changeValidator.next.stake, nextSeatPrice)));
diff.removedValidators.forEach((validator) => nextValidatorsTable.addRow('Kicked out', validator.account_id, '-', '-'));
console.log(nextValidatorsTable.toString());
}
Expand Down Expand Up @@ -102,7 +102,7 @@ async function showProposalsTable(near) {
kind,
proposal.account_id,
stake_fmt,
new BN(proposal.stake).div(expectedSeatPrice)
getNumberOfSeats(result.protocolConfig.protocol_version, proposal.stake, expectedSeatPrice)
);
});
console.log(proposalsTable.toString());
Expand All @@ -111,4 +111,9 @@ async function showProposalsTable(near) {
console.log('Note: this currently doesn\'t account for offline kickouts and rewards for current epoch');
}

// starting from protocol version 49 each validator has 1 seat
function getNumberOfSeats(protocolVersion, stake, seatPrice) {
return protocolVersion < 49 ? new BN(stake).div(seatPrice) : new BN(1);
}

module.exports = { showValidatorsTable, showNextValidatorsTable, showProposalsTable };

0 comments on commit b9d499f

Please sign in to comment.