-
Notifications
You must be signed in to change notification settings - Fork 0
BAM writer service: Track BAM metrics #35
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
base: master
Are you sure you want to change the base?
Conversation
#### API - Added new endpoint bam_epoch_metrics - Returns bam metric info such as `bam_total_stake_weight`, `available_bam_delegation_stake`, `eligible_bam_validator_count` - Modified the endpoint `validators` to add new fields `jito_pool_eligible`, `jito_pool_directed_stake_target` #### Bam Writer Service - Service for BAM delegation calculations, tracking network-wide BAM validator participation and computing available JitoSOL delegation based on [JIP-28 specifications](https://forum.jito.network/t/jip-28-accelerate-bam-adoption/904).
| │ Kobe API │ │ | ||
| │ (Data Access) │ ────────────────────────────────────────────────── | ||
| │ │ | ||
| └─────────────────┘ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this
| /// Epoch number | ||
| epoch: u64, | ||
|
|
||
| /// Totoal JitoSOL TVL in lamports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Total
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed 294223f
| allocation_bps: u64, | ||
|
|
||
| /// Available BAM delegation stake amount in lamports | ||
| available_bam_delegation_stake: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update the comment to mention how this is the stake for JitoSOL delegation based on the current % of active stake running BAM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed 294223f
api/src/main.rs
Outdated
| get(get_validator_histories), | ||
| ) | ||
| .route( | ||
| "/api/v1/bam_epoch_metric", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere in the PR that says "bam epoch metric" should be replaced with "bam epoch metrics"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! addressed 9c73b01
bam-writer-service/src/main.rs
Outdated
| args.epoch_progress_threshold, | ||
| poll_interval, | ||
| ) | ||
| .await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider running this multiple times if we find that we need more redundancy or if validators are optimizing their BAM connectivity to be detected by this writer service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled to run multiple times like thresholds 50%, 75% 90% of epoch progress
bam-writer-service/src/lib.rs
Outdated
| } | ||
|
|
||
| self.bam_validators_store | ||
| .insert_many(&bam_validators) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upsert is better practice here I think in the case that we run multiple times per epoch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense! switch to upsert method
| /// Retrieves the list of BAM (Block Auction Mechanism) validators based on the cluster configuration. | ||
| /// | ||
| /// # Behavior | ||
| /// | ||
| /// - **Localnet/Testnet**: Returns a static list of mock validators for testing purposes. | ||
| /// The mock data includes two validators with equal stake distribution (50% each). | ||
| /// | ||
| /// - **Mainnet**: Fetches the live validator list from the BAM API endpoint. | ||
| async fn get_bam_validators(&self) -> anyhow::Result<Vec<ValidatorsResponse>> { | ||
| match self.cluster { | ||
| Cluster::Localnet | Cluster::Testnet => { | ||
| let res = vec![ | ||
| ValidatorsResponse { | ||
| validator_pubkey: "FT9QgTVo375TgDAQusTgpsfXqTosCJLfrBpoVdcbnhtS" | ||
| .to_string(), | ||
| bam_node_connection: "testnet-bam-1".to_string(), | ||
| stake: 1500000.0, | ||
| stake_percentage: 0.50, | ||
| }, | ||
| ValidatorsResponse { | ||
| validator_pubkey: "141vSYKGRPNGieSrGJy8EeDVBcbjSr6aWkimNgrNZ6xN" | ||
| .to_string(), | ||
| bam_node_connection: "testnet-bam-1".to_string(), | ||
| stake: 1500000.0, | ||
| stake_percentage: 0.50, | ||
| }, | ||
| ]; | ||
|
|
||
| Ok(res) | ||
| } | ||
| Cluster::Mainnet => { | ||
| let bam_api_config = | ||
| bam_api_client::config::Config::custom(self.bam_api_base_url.clone()); | ||
| let bam_api_client = BamApiClient::new(bam_api_config); | ||
|
|
||
| bam_api_client | ||
| .get_validators() | ||
| .await | ||
| .map_err(|e| anyhow!("Failed to get bam validators: {e}")) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the api for test is not ready, we will use fake values for testnet
API
bam_total_stake_weight,available_bam_delegation_stake,eligible_bam_validator_countvalidatorsto add new fieldsjito_pool_eligible,jito_pool_directed_stake_targetBam Writer Service
specifications.
Writer Service