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

Use proposer index cache for block proposal #4313

Open
michaelsproul opened this issue May 22, 2023 · 2 comments
Open

Use proposer index cache for block proposal #4313

michaelsproul opened this issue May 22, 2023 · 2 comments
Assignees
Labels
consensus An issue/PR that touches consensus code, such as state_processing or block verification. optimization Something to make Lighthouse run more efficiently.

Comments

@michaelsproul
Copy link
Member

Description

During block proposal we compute the proposer index from scratch here:

let proposer_index = state.get_beacon_proposer_index(state.slot(), &self.spec)? as u64;

Steps to resolve

We should use the beacon proposer cache, like this:

let cached_proposer = self
.beacon_proposer_cache
.lock()
.get_slot::<T::EthSpec>(shuffling_decision_root, proposal_slot);
let proposer_index = if let Some(proposer) = cached_proposer {
proposer.index as u64

On a cache miss we could either fall back to computing the index as we do now, or we could prime the cache using the available beacon state. The disadvantage of priming the cache is that it delays the getPayload request to the builder/execution layer. However, we might end up needing to prime the cache anyway. If we fix #4264 then gossip verification will try to prime the cache here:

debug!(
chain.log,
"Proposer shuffling cache miss";
"parent_root" => ?parent.beacon_block_root,
"parent_slot" => parent.beacon_block.slot(),
"block_root" => ?block_root,
"block_slot" => block.slot(),
);

Therefore I think we may as well try priming the cache if we miss. It's more future proof.

@michaelsproul michaelsproul added optimization Something to make Lighthouse run more efficiently. consensus An issue/PR that touches consensus code, such as state_processing or block verification. labels May 22, 2023
@int88
Copy link
Contributor

int88 commented May 23, 2023

I'd like to work on it 😃 @michaelsproul

@michaelsproul
Copy link
Member Author

great! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus An issue/PR that touches consensus code, such as state_processing or block verification. optimization Something to make Lighthouse run more efficiently.
Projects
None yet
Development

No branches or pull requests

2 participants