rusk
rusk copied to clipboard
Improve provisioners cache
Summary
Current provisioners cache is updated in different scenarios:
- Epoch changed (to include new stakers)
- Unstake transaction is successfully executed (to remove unstaked provisioner)
- Slash occurs (to update eligibility and stake amount of the slashed provisioner)
- Fallback (to reload the provisioners at that specific point in time)
- Startup
Cache is updated this way:
- Get all provisioners from the stake contract
- Replace the list
This can be a performance issue when provisioners count is quite high.
Indeed a get_provisioners
call can get up to 6/7 secs for ~700 provisioners.
This is caused by the not-optimal implementation of the stake-contract that perform a lot of canonical serializations back and forth without taking advantage of rkyv serialization
Possible solution design or implementation
- Upgrade the stake contract to be more performant
- Change how the node is currently updating the provisioners (maybe refreshing just the state of the single provisioner who need an update). This would not remove the need of
get_provisioners
during fallback and startup - Rely on smart contract events
Additional context
- Rely on smart contract events
Closed since we don't really have a problem here anymore after solving #1435 and #1636