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

Emit scoring details and instant unstake details in V2 events #81

Merged
merged 13 commits into from
Sep 12, 2024
271 changes: 271 additions & 0 deletions programs/steward/idl/steward.json
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,19 @@
77
]
},
{
"name": "InstantUnstakeComponentsV2",
"discriminator": [
138,
62,
181,
14,
9,
48,
109,
47
]
},
{
"name": "RebalanceEvent",
"discriminator": [
Expand All @@ -1646,6 +1659,19 @@
251
]
},
{
"name": "ScoreComponentsV2",
"discriminator": [
140,
182,
108,
49,
246,
38,
247,
181
]
},
{
"name": "StateTransition",
"discriminator": [
Expand Down Expand Up @@ -2315,6 +2341,47 @@
},
{
"name": "InstantUnstakeComponents",
"docs": [
"Deprecated: This struct is no longer emitted but is kept to allow parsing of old events.",
"Because the event discriminator is based on struct name, it's important to rename the struct if",
"fields are changed."
],
"type": {
"kind": "struct",
"fields": [
{
"name": "instant_unstake",
"type": "bool"
},
{
"name": "delinquency_check",
"type": "bool"
},
{
"name": "commission_check",
"type": "bool"
},
{
"name": "mev_commission_check",
"type": "bool"
},
{
"name": "is_blacklisted",
"type": "bool"
},
{
"name": "vote_account",
"type": "pubkey"
},
{
"name": "epoch",
"type": "u16"
}
]
}
},
{
"name": "InstantUnstakeComponentsV2",
"type": {
"kind": "struct",
"fields": [
Expand Down Expand Up @@ -2360,6 +2427,67 @@
{
"name": "epoch",
"type": "u16"
},
{
"name": "details",
"docs": [
"Details about why a given check was calculated"
],
"type": {
"defined": {
"name": "InstantUnstakeDetails"
}
}
}
]
}
},
{
"name": "InstantUnstakeDetails",
"type": {
"kind": "struct",
"fields": [
{
"name": "epoch_credits_latest",
"docs": [
"Latest epoch credits"
],
"type": "u64"
},
{
"name": "vote_account_last_update_slot",
"docs": [
"Latest vote account update slot"
],
"type": "u64"
},
{
"name": "total_blocks_latest",
"docs": [
"Latest total blocks"
],
"type": "u32"
},
{
"name": "cluster_history_slot_index",
"docs": [
"Cluster history slot index"
],
"type": "u64"
},
{
"name": "commission",
"docs": [
"Commission value"
],
"type": "u8"
},
{
"name": "mev_commission",
"docs": [
"MEV commission value"
],
"type": "u16"
}
]
}
Expand Down Expand Up @@ -2617,6 +2745,67 @@
},
{
"name": "ScoreComponents",
"docs": [
"Deprecated: This struct is no longer emitted but is kept to allow parsing of old events.",
"Because the event discriminator is based on struct name, it's important to rename the struct if",
"fields are changed."
],
"type": {
"kind": "struct",
"fields": [
{
"name": "score",
"type": "f64"
},
{
"name": "yield_score",
"type": "f64"
},
{
"name": "mev_commission_score",
"type": "f64"
},
{
"name": "blacklisted_score",
"type": "f64"
},
{
"name": "superminority_score",
"type": "f64"
},
{
"name": "delinquency_score",
"type": "f64"
},
{
"name": "running_jito_score",
"type": "f64"
},
{
"name": "commission_score",
"type": "f64"
},
{
"name": "historical_commission_score",
"type": "f64"
},
{
"name": "vote_credits_ratio",
"type": "f64"
},
{
"name": "vote_account",
"type": "pubkey"
},
{
"name": "epoch",
"type": "u16"
}
]
}
},
{
"name": "ScoreComponentsV2",
"type": {
"kind": "struct",
"fields": [
Expand Down Expand Up @@ -2698,6 +2887,88 @@
{
"name": "epoch",
"type": "u16"
},
{
"name": "details",
"docs": [
"Details about why a given score was calculated"
],
"type": {
"defined": {
"name": "ScoreDetails"
}
}
}
]
}
},
{
"name": "ScoreDetails",
"type": {
"kind": "struct",
"fields": [
{
"name": "max_mev_commission",
"docs": [
"Max MEV commission observed"
],
"type": "u16"
},
{
"name": "max_mev_commission_epoch",
"docs": [
"Epoch of max MEV commission"
],
"type": "u16"
},
{
"name": "superminority_epoch",
"docs": [
"Epoch when superminority was detected"
],
"type": "u16"
},
{
"name": "delinquency_ratio",
"docs": [
"Ratio that failed delinquency check"
],
"type": "f64"
},
{
"name": "delinquency_epoch",
"docs": [
"Epoch when delinquency was detected"
],
"type": "u16"
},
{
"name": "max_commission",
"docs": [
"Max commission observed"
],
"type": "u8"
},
{
"name": "max_commission_epoch",
"docs": [
"Epoch of max commission"
],
"type": "u16"
},
{
"name": "max_historical_commission",
"docs": [
"Max historical commission observed"
],
"type": "u8"
},
{
"name": "max_historical_commission_epoch",
"docs": [
"Epoch of max historical commission"
],
"type": "u16"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions programs/steward/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub const BASIS_POINTS_MAX: u16 = 10_000;
pub const COMMISSION_MAX: u8 = 100;
pub const SORTED_INDEX_DEFAULT: u16 = u16::MAX;
pub const LAMPORT_BALANCE_DEFAULT: u64 = u64::MAX;
pub const EPOCH_DEFAULT: u16 = u16::MAX;
// Need at least 1% of slots remaining (4320 slots) to execute steps in state machine
pub const EPOCH_PROGRESS_MAX: f64 = 0.99;
// Cannot go more than 100 epochs without scoring
Expand Down
35 changes: 35 additions & 0 deletions programs/steward/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,38 @@ impl IdlBuild for RebalanceTypeTag {
})
}
}

/// Deprecated: This struct is no longer emitted but is kept to allow parsing of old events.
/// Because the event discriminator is based on struct name, it's important to rename the struct if
/// fields are changed.
#[event]
#[derive(Debug, PartialEq)]
pub struct ScoreComponents {
pub score: f64,
pub yield_score: f64,
pub mev_commission_score: f64,
pub blacklisted_score: f64,
pub superminority_score: f64,
pub delinquency_score: f64,
pub running_jito_score: f64,
pub commission_score: f64,
pub historical_commission_score: f64,
pub vote_credits_ratio: f64,
pub vote_account: Pubkey,
pub epoch: u16,
}

/// Deprecated: This struct is no longer emitted but is kept to allow parsing of old events.
/// Because the event discriminator is based on struct name, it's important to rename the struct if
/// fields are changed.
#[event]
#[derive(Debug, PartialEq, Eq)]
pub struct InstantUnstakeComponents {
pub instant_unstake: bool,
pub delinquency_check: bool,
pub commission_check: bool,
pub mev_commission_check: bool,
pub is_blacklisted: bool,
pub vote_account: Pubkey,
pub epoch: u16,
}
Loading
Loading