From cc3b3e41cdeb1fa0bf0ff089dba893b8a2f3d7c4 Mon Sep 17 00:00:00 2001 From: davidlucid Date: Thu, 23 Sep 2021 18:45:47 -0500 Subject: [PATCH] Fix bug: block number needs to be updated when setting reward speed again after it has been unset Bug #2 described in this post: https://www.comp.xyz/t/comptroller-compspeed-bug/2111 --- contracts/RewardsDistributor.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contracts/RewardsDistributor.sol b/contracts/RewardsDistributor.sol index 1f1419305..0861cc1d4 100644 --- a/contracts/RewardsDistributor.sol +++ b/contracts/RewardsDistributor.sol @@ -179,6 +179,9 @@ contract RewardsDistributor is ExponentialNoError { if (compBorrowState[address(cToken)].index == 0) { allMarkets.push(cToken); } + } else { + // Update block number to ensure extra interest is not accrued during the prior period + compSupplyState[address(cToken)].block = safe32(getBlockNumber(), "block number exceeds 32 bits"); } } @@ -214,6 +217,9 @@ contract RewardsDistributor is ExponentialNoError { if (compSupplyState[address(cToken)].index == 0) { allMarkets.push(cToken); } + } else { + // Update block number to ensure extra interest is not accrued during the prior period + compBorrowState[address(cToken)].block = safe32(getBlockNumber(), "block number exceeds 32 bits"); } }