Skip to content

Conversation

@wen-coding
Copy link
Contributor

Add CertificatePoolStats as promised in https://github.com/anza-xyz/alpenglow/pull/307/files#r2223736794

During the process, also realized we are not currently rejecting certificates older than root, which is a bug.

Fixed bug and added tests.

}
}

fn reset(&mut self) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could just set to default here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

);

datapoint_info!(
"certificate_pool_ingested_votes_by_type",
Copy link
Contributor

Choose a reason for hiding this comment

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

could probably drop the _by_type postfix for these metrics just to reduce verbosity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


if self.ingested_votes_by_type.len() <= index {
self.ingested_votes_by_type
.resize(index.saturating_add(1), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

don't love this.. maybe we could use something like strum to help derive number of enums and set the Vec size properly up front?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, since the type of Vote/Cert in Alpenglow will not change that fast, I can use the last_constant + 1. If we ever change this, we should see panic in tests because I was using array[index]. Does that work?

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds okay to me

pub(crate) event_safe_to_notarize: u32,

pub(crate) exits: [u32; 2],
pub(crate) incoming: [u32; 2],
Copy link
Contributor

Choose a reason for hiding this comment

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

probably easier to just have incoming_votes and incoming_certs fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

pub fn incr_u32_array(value: &mut [u32; 2], is_vote: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we could get rid of this if we get rid of the arrays

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

}
}

pub fn incr_u32(value: &mut u32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this? I think we can just call self.value = self.value.saturating_add(1); directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just being lazy, removed.

@wen-coding wen-coding requested a review from bw-solana July 24, 2025 04:09
Copy link
Contributor

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

Overall, LGTM!

Only thing I don't love is burying stats reporting down deep and being reliant on receiving a BLS message (although I agree this should be happening pretty much all the time)

events: &mut Vec<VotorEvent>,
) -> Result<(Option<Slot>, Vec<Arc<CertificateMessage>>), AddVoteError> {
// We add stats reporting here because we should almost always have a message.
self.stats.maybe_report();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking this might fit better higher up the stack (like in certificate_pool_ingest main loop). If we move it up there, we could even make this a sub-component of the CertificatePoolServiceStats reporting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I don't think the two stats should be mixed together, they each maintain the status of the corresponding data structure.

But I can move the trigger there. Done.

stats.maybe_report();
if stats.maybe_report() {
// Stats were reported, report the certificate pool stats
cert_pool.report_stats();
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're going to decouple the service and pool stats, might as well fully decouple them and just call something like this in succession:

stats.maybe_report();
cert_pool.maybe_report();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@wen-coding wen-coding merged commit 1b625ff into anza-xyz:master Jul 24, 2025
7 checks passed
@wen-coding wen-coding deleted the add_certificate_pool_stats branch July 24, 2025 20:18
@wen-coding wen-coding linked an issue Jul 25, 2025 that may be closed by this pull request
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 1, 2025
bw-solana pushed a commit to bw-solana/alpenglow that referenced this pull request Aug 2, 2025
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.

Broadcast new certificates in certificate_service to all-to-all

2 participants