onflow/flow-core-contracts

SoR history gaps when heartbeat call fails

Closed this issue · 1 comments

Problem

The current SoR history contract assumes a heartbeat function is called at every block to record the SoR corresponding to that block. This is currently done by a system transaction included in every block. Recently (Feb 2024), an update to core-contracts has caused the heartbeat function to fail (this is because of the way dependant contracts get updated, and is outside of the scope of this issue). This resulted in the SoR history not being recorded for a range of blocks (till the core-contracts got back to a working state).
The SoR corresponding to a block of height h is now only available after the gap length (about 200 blocks), instead of right away at height h+1. While there is no security impact of this failure as the SoR committed to in a height h is still unpredictable and is only revealed in a future block, the delay in revealing the SoR isn't ideal for applications. Moreover, accessing the SoR history on a block index h, returns the the SoR generated by the protocol in block h-200.

Fix

  • update the SoR history contract to be more robust against occasional non calls of the heartbeat function in some blocks. Upgrading the contract should also fix the current on-chain state of the SoR array.