Skip to content

refactor: do not store epoch related state in CertificatePool#360

Merged
akhi3030 merged 10 commits intomasterfrom
akhi3030/cert-pool-no-epoch-stakes
Aug 8, 2025
Merged

refactor: do not store epoch related state in CertificatePool#360
akhi3030 merged 10 commits intomasterfrom
akhi3030/cert-pool-no-epoch-stakes

Conversation

@akhi3030
Copy link
Copy Markdown
Contributor

@akhi3030 akhi3030 commented Aug 6, 2025

Instead of caching epoch related state in the CertificatePool, pass it into the pool. This removes dependencies between banks and other related structs like the RootBankCache, and BankForks, etc.

Comment thread votor/src/certificate_pool.rs Outdated
@akhi3030 akhi3030 force-pushed the akhi3030/cert-pool-no-epoch-stakes branch 3 times, most recently from 64bddef to 7100785 Compare August 6, 2025 15:16
@akhi3030 akhi3030 changed the title wip wip: refactor: do not store epoch related state in CertificatePool Aug 6, 2025
@akhi3030 akhi3030 force-pushed the akhi3030/cert-pool-no-epoch-stakes branch 2 times, most recently from 252b512 to 8c2fd9a Compare August 6, 2025 15:25
Comment thread votor/src/certificate_pool.rs Outdated
@akhi3030 akhi3030 force-pushed the akhi3030/cert-pool-no-epoch-stakes branch 3 times, most recently from 4d4705d to 8dc2224 Compare August 6, 2025 19:25
@akhi3030 akhi3030 marked this pull request as ready for review August 6, 2025 19:36
@akhi3030 akhi3030 changed the title wip: refactor: do not store epoch related state in CertificatePool refactor: do not store epoch related state in CertificatePool Aug 6, 2025
@akhi3030 akhi3030 enabled auto-merge (squash) August 6, 2025 19:37
Comment thread votor/src/certificate_pool.rs Outdated
Comment thread votor/src/certificate_pool_service.rs Outdated
Comment thread votor/src/certificate_pool_service.rs Outdated
Comment thread votor/src/certificate_pool_service.rs Outdated
let (new_finalized_slot, new_certificates_to_send) = cert_pool.add_message(
bank.epoch_schedule(),
bank.epoch_stakes_map(),
bank.slot(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious, why is passing three members of a Bank better than passing bank itself?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

because then the pool depends upon the bank for information that only changes once an epoch. We need to clean things up so that we are not unnecessarily using banks for information that should be stored in an object like EpochInfo.

Comment thread votor/src/certificate_pool.rs
@akhi3030 akhi3030 force-pushed the akhi3030/cert-pool-no-epoch-stakes branch from ef2061c to 155111b Compare August 7, 2025 08:11
Comment thread votor/src/certificate_pool.rs
Comment thread votor/src/certificate_pool.rs Outdated
Comment thread votor/src/certificate_pool.rs
Comment thread votor/src/certificate_pool.rs Outdated
Comment thread votor/src/certificate_pool_service.rs
Comment thread votor/src/certificate_pool.rs
Comment thread votor/src/certificate_pool.rs
Comment thread votor/src/certificate_pool.rs
pub(crate) certificates_sent: u16,
pub(crate) certificates_dropped: u16,
pub(crate) new_finalized_slot: u16,
pub(crate) new_root: u16,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should add a count for cleanup we've done....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do you mean the number of times we have called cleanup?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yup, so if suddenly we don't accept any incoming votes/certs we can check whether a cleanup happened.

}

#[derive(Default)]
fn get_key_and_stakes(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this also probably shouldn't be in certificate_pool

let vote_type = VoteType::get_type(vote);
if let Some(conflicting_type) =
self.has_conflicting_vote(slot, vote_type, &validator_vote_key, &block_id)
self.has_conflicting_vote(vote_slot, vote_type, &validator_vote_key, &block_id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should not to be part of this PR, but why do we turn the rank into the vote key and then use the vote key to index validators? I think we should only use the rank within all of Pool


fn add_certificate(
&mut self,
root_slot: Slot,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should not care about the root at all, but I guess that will be part of #368

@akhi3030 akhi3030 merged commit 574bf70 into master Aug 8, 2025
8 checks passed
@akhi3030 akhi3030 deleted the akhi3030/cert-pool-no-epoch-stakes branch August 8, 2025 10:25
@akhi3030
Copy link
Copy Markdown
Contributor Author

akhi3030 commented Aug 8, 2025

This PR was accidentally merged. I'll make a new one with some of the changes requested above.

@akhi3030
Copy link
Copy Markdown
Contributor Author

akhi3030 commented Aug 8, 2025

#384 covers the remaining review comments.

akhi3030 added a commit that referenced this pull request Aug 9, 2025
#360 was accidentally merged and not all review comments were addressed. This PR addresses the remaining comments.
AshwinSekar pushed a commit to AshwinSekar/alpenglow that referenced this pull request Feb 23, 2026
…nza-xyz#360)

Instead of caching epoch related state in the CertificatePool, pass it into the pool. This removes dependencies between banks and other related structs like the RootBankCache, and BankForks, etc.

Also updates cleanup() to use the highest finalized slot instead of the root slot which is in line with the paper.
AshwinSekar pushed a commit to AshwinSekar/alpenglow that referenced this pull request Feb 23, 2026
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.

5 participants