From 224eca774092511f6b003bcf7380debd0eb8d1d7 Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Sat, 11 Nov 2023 09:52:33 -0800 Subject: [PATCH] add precondition that ref epoch in the past guarantees time computation doesn't underflow --- contracts/epochs/FlowEpoch.cdc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contracts/epochs/FlowEpoch.cdc b/contracts/epochs/FlowEpoch.cdc index 10ff8de5e..5e91ee898 100644 --- a/contracts/epochs/FlowEpoch.cdc +++ b/contracts/epochs/FlowEpoch.cdc @@ -375,6 +375,9 @@ pub contract FlowEpoch { } pub fun updateEpochTimingConfig(_ newConfig: EpochTimingConfig) { + pre { + FlowEpoch.currentEpochCounter >= newConfig.refCounter: "Reference epoch must be before next epoch" + } FlowEpoch.account.load(from: /storage/flowEpochTimingConfig) FlowEpoch.account.save(newConfig, to: /storage/flowEpochTimingConfig) }