Skip to content

Conversation

@aoikurokawa
Copy link
Collaborator

@aoikurokawa aoikurokawa commented Nov 16, 2025

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
    .

Writer Service

#### 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).
@aoikurokawa aoikurokawa marked this pull request as ready for review November 16, 2025 03:02
│ Kobe API │ │
│ (Data Access) │ ──────────────────────────────────────────────────
│ │
└─────────────────┘
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Total

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops

Copy link
Collaborator Author

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,
Copy link
Collaborator

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

Copy link
Collaborator Author

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",
Copy link
Collaborator

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"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! addressed 9c73b01

args.epoch_progress_threshold,
poll_interval,
)
.await
Copy link
Collaborator

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

Copy link
Collaborator Author

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

}

self.bam_validators_store
.insert_many(&bam_validators)
Copy link
Collaborator

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

Copy link
Collaborator Author

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

Comment on lines +87 to +128
/// 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}"))
}
}
}
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants