Increase pointer by 67 blocks each time the period is increased (#75)
* Increase pointer by 67 instead of 64 for each period Use a prime number to ensure that we don't get cycles where we're looking at the same hash four periods from now. --------- Co-authored-by: Mark Spanbroek <mark@spanbroek.net>
This commit is contained in:
parent
87461f6b83
commit
b5f33992b6
|
@ -36,7 +36,10 @@ abstract contract Proofs is Periods {
|
|||
|
||||
function _getPointer(SlotId id, Period period) internal view returns (uint8) {
|
||||
uint256 blockNumber = block.number % 256;
|
||||
uint256 periodNumber = Period.unwrap(period) % 256;
|
||||
// To ensure the pointer does not remain in downtime for many consecutive
|
||||
// periods, for each period increase, move the pointer 67 blocks. We've
|
||||
// chosen a prime number to ensure that we don't get cycles.
|
||||
uint256 periodNumber = (Period.unwrap(period) * 67) % 256;
|
||||
uint256 idOffset = uint256(SlotId.unwrap(id)) % 256;
|
||||
uint256 pointer = (blockNumber + periodNumber + idOffset) % 256;
|
||||
return uint8(pointer);
|
||||
|
|
Loading…
Reference in New Issue