-
Notifications
You must be signed in to change notification settings - Fork 801
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
Optimise calculation of proposer indices #598
Comments
Blocked on merging of v0.9 into master: #597 |
Hey @michaelsproul is this still relevant? |
I'd concluded that it wasn't really worth doing, because the calculation of a single proposer index doesn't seem to take that long. But I will confirm this suspicion with a benchmark on 100k validators (I think last I looked was with 16k validators) |
I did some benchmarks
Noting that we currently do two proposer calculations per block processed, the calls to (all benchmarks run using mainnet spec, |
Great find! Good to know we have this up our sleeve! |
Description
In v0.9 of the spec, proposer selection was changed so that it depends on a per slot shuffling of the active validators. This invalidates any attempt to use the existing committee cache to compute the proposer, but doesn't rule out doing something else clever.
The relevant functions in the spec are
get_beacon_proposer_index
andcompute_proposer_index
.Present Behaviour
With #597, I've taken the simplest approach of recomputing the (ordered) active validators and their shuffling each time the beacon proposer for a slot is requested.
Proposed Behaviour
We could construct a cache of proposer indices at the start of each epoch. This would look like a
Vec<u64>
of lengthSLOTS_PER_EPOCH
, that contains the Beacon proposer index for each slot of the epoch at vec indexslot % SLOTS_PER_EPOCH
.We are able to compute this cache because the selection of proposers depends upon:
hash(get_seed(state, epoch, DOMAIN_BEACON_PROPOSER) + int_to_bytes(slot, length=8))
for all slots in the epoch.process_final_updates
function as part of an epoch transition, and are therefore stable for the entirety of the epoch. Unlike the committee cache which we can compute a full epoch in advance, the dependence on the effective balances (which change right up to the end of the previous epoch), prevents us from computing the proposer index cache until we transition into the current epoch.The text was updated successfully, but these errors were encountered: