rusk icon indicating copy to clipboard operation
rusk copied to clipboard

Improve provisioners cache

Open herr-seppia opened this issue 1 year ago • 1 comments

Summary

Current provisioners cache is updated in different scenarios:

  1. Epoch changed (to include new stakers)
  2. Unstake transaction is successfully executed (to remove unstaked provisioner)
  3. Slash occurs (to update eligibility and stake amount of the slashed provisioner)
  4. Fallback (to reload the provisioners at that specific point in time)
  5. 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

  1. Upgrade the stake contract to be more performant
  2. 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
  3. Rely on smart contract events

Additional context

herr-seppia avatar Feb 21 '24 09:02 herr-seppia

  1. Rely on smart contract events

herr-seppia avatar Mar 12 '24 09:03 herr-seppia

Closed since we don't really have a problem here anymore after solving #1435 and #1636

autholykos avatar Jun 28 '24 07:06 autholykos