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

score-all command #119

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c405573
make stake pool optional, score-all command
luciotato Jun 26, 2021
fc01071
generate validator-detail.csv
luciotato Jun 27, 2021
697502f
Merge branch 'solana-labs:master' into scorer
luciotato Jun 27, 2021
3e0b405
skip heavy rpc-call, ensure all validators scored
luciotato Jun 27, 2021
c6758e4
Merge
luciotato Jun 27, 2021
f56159c
compute score
luciotato Jun 27, 2021
bd6464f
scripts
luciotato Jun 27, 2021
a700608
parametrize score, do not combine with --confirm
luciotato Jun 30, 2021
1f82f09
fix score-all arguments
luciotato Jul 3, 2021
b562d35
score-all command
luciotato Jul 3, 2021
a4b97a2
add vote-address
luciotato Jul 17, 2021
b9299ca
do not include .vscode
luciotato Jul 17, 2021
a9f3716
Merge master
luciotato Jul 17, 2021
4b78d56
Merge upstream into solana-labs-master
luciotato Jul 17, 2021
d4e4d49
Merge branch 'solana-labs-master'
luciotato Jul 17, 2021
4fdaed2
remove comment block as requested
luciotato Jul 17, 2021
f971ff4
make stake pool optional, score-all command
luciotato Jun 26, 2021
4608fa9
skip heavy rpc-call, ensure all validators scored
luciotato Jun 27, 2021
8a3df58
add vote-address
luciotato Jul 17, 2021
004b7bd
remove comment block as requested
luciotato Jul 17, 2021
528d339
Merge origin
luciotato Jul 17, 2021
c55c904
remove unused var
luciotato Jul 17, 2021
351f31d
act on recommendation - db backward compat
luciotato Jul 24, 2021
e7aa268
add average-position, recompute score every time
luciotato Jul 25, 2021
6eb887e
fix csv headers
luciotato Jul 25, 2021
d6c5dc5
score-all mainnet
luciotato Jul 30, 2021
480b52b
set limit to 33%
luciotato Jul 31, 2021
f3651d4
include 1st outside sec-group
luciotato Jul 31, 2021
8be79ad
apply commission discount to credits more fairly
luciotato Aug 1, 2021
1817d01
better name for table field
luciotato Aug 3, 2021
2a58220
add validator-name, min-avg-position
luciotato Aug 10, 2021
dd30b2b
select top X validators
luciotato Aug 14, 2021
8028451
tilt towards high average
luciotato Aug 18, 2021
c8bdc27
apply data-center concentration penalty
luciotato Aug 21, 2021
72824f3
take TOP 200 validators
luciotato Sep 3, 2021
04738cb
add comments to sql processing
luciotato Sep 12, 2021
92e3c43
new field adj_credits
luciotato Sep 16, 2021
28943a5
add active stake
luciotato Oct 19, 2021
4caeccd
move to avg last 5 epochs
luciotato Nov 2, 2021
bab763f
set score=0 if stake<100
luciotato Nov 7, 2021
81bbd28
extend score cut to top 250
luciotato Nov 21, 2021
879de8d
sql-utils
luciotato Dec 26, 2021
03c8bc9
include last validator in nakamoto coeff
luciotato Dec 31, 2021
6fff2be
Dockerized (#3)
janlegner Jan 19, 2022
d4798c6
Fixed double quotes escaping
janlegner Jan 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/registry-cli
/db
test-ledger/
.vscode
40 changes: 40 additions & 0 deletions bot/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use {
crate::{
data_center_info::{DataCenterId, DataCenterInfo},
generic_stake_pool::ValidatorStakeState,
Config,
},
log::*,
serde::{Deserialize, Serialize},
Expand All @@ -14,6 +15,13 @@ use {
},
};

#[derive(Default, Clone, Deserialize, Serialize)]
pub struct ScoreDiscounts {
pub low_credits: bool,
pub insufficient_self_stake: bool,
pub can_halt_the_network_group: bool,
}

#[derive(Default, Clone, Deserialize, Serialize)]
pub struct ValidatorClassification {
pub identity: Pubkey, // Validator identity
Expand All @@ -22,6 +30,13 @@ pub struct ValidatorClassification {
pub stake_state: ValidatorStakeState,
pub stake_state_reason: String,

/// computed score (more granular than ValidatorStakeState)
pub epoch_credits: u64, // epoch_credits is the base score
pub score_discounts: ScoreDiscounts,
pub commission: u8,
pub active_stake: u64,
pub data_center_concentration: f64,

Copy link
Contributor

@mvines mvines Jul 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to avoid breaking the existing database entries, the new fields here need to each be wrapped in an Option<>. You might find it easier to move them all out into a single struct and wrap an Option around just that struct

// Summary of the action was taken this epoch to advance the validator's stake
pub stake_action: Option<String>,

Expand All @@ -46,6 +61,31 @@ pub struct ValidatorClassification {
}

impl ValidatorClassification {
pub fn score(&self, config: &Config) -> u64 {
if self.score_discounts.can_halt_the_network_group
|| self.score_discounts.insufficient_self_stake
|| self.score_discounts.low_credits
|| self.commission > config.score_max_commission
|| self.active_stake < config.score_min_stake
{
0
} else {
// if data_center_concentration = 25%, lose all score,
// data_center_concentration = 10%, lose 40% (rounded)
let discount_because_data_center_concentration =
self.epoch_credits * (self.data_center_concentration as u64 * 4) / 100;

// score discounts according to commission
let discount_because_commission =
(self.commission as u32 * config.score_commission_discount) as u64;

//result
self.epoch_credits
.saturating_sub(discount_because_commission)
.saturating_sub(discount_because_data_center_concentration)
}
}

pub fn stake_state_streak(&self) -> usize {
let mut streak = 1;

Expand Down
Loading