From 8f079ff28ef86f7cf31fa3c7bfdb5bfe4a1235ed Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Wed, 16 Aug 2023 13:18:09 -0300 Subject: [PATCH] Revert "bonding: Use memory instead of storage for checkpoints" This reverts commit ec801e26101678899706ab805760daaf23165173. --- contracts/bonding/BondingVotes.sol | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/contracts/bonding/BondingVotes.sol b/contracts/bonding/BondingVotes.sol index efb20625..58d0bd4c 100644 --- a/contracts/bonding/BondingVotes.sol +++ b/contracts/bonding/BondingVotes.sol @@ -337,7 +337,7 @@ contract BondingVotes is ManagerProxyTarget, IBondingVotes { virtual returns (uint256 amount, address delegateAddress) { - BondingCheckpoint memory bond = getBondingCheckpointAt(_account, _round); + BondingCheckpoint storage bond = getBondingCheckpointAt(_account, _round); delegateAddress = bond.delegateAddress; bool isTranscoder = delegateAddress == _account; @@ -362,7 +362,11 @@ contract BondingVotes is ManagerProxyTarget, IBondingVotes { * @param _round The round for which we want to get the bonding state. * @return The {BondingCheckpoint} pointer to the checkpoints storage. */ - function getBondingCheckpointAt(address _account, uint256 _round) internal view returns (BondingCheckpoint memory) { + function getBondingCheckpointAt(address _account, uint256 _round) + internal + view + returns (BondingCheckpoint storage) + { if (_round > clock() + 1) { revert FutureLookup(_round, clock() + 1); } @@ -371,7 +375,7 @@ contract BondingVotes is ManagerProxyTarget, IBondingVotes { // Most of the time we will be calling this for a transcoder which checkpoints on every round through reward(). // On those cases we will have a checkpoint for exactly the round we want, so optimize for that. - BondingCheckpoint memory bond = checkpoints.data[_round]; + BondingCheckpoint storage bond = checkpoints.data[_round]; if (bond.bondedAmount > 0) { return bond; } @@ -395,7 +399,11 @@ contract BondingVotes is ManagerProxyTarget, IBondingVotes { * @param _round The round for which we want to get the cumulative stake. * @return The cumulative stake of the delegator at the given round. */ - function delegatorCumulativeStakeAt(BondingCheckpoint memory bond, uint256 _round) internal view returns (uint256) { + function delegatorCumulativeStakeAt(BondingCheckpoint storage bond, uint256 _round) + internal + view + returns (uint256) + { EarningsPool.Data memory startPool = getTranscoderEarningsPoolForRound( bond.delegateAddress, bond.lastClaimRound @@ -436,7 +444,7 @@ contract BondingVotes is ManagerProxyTarget, IBondingVotes { view returns (uint256 rewardRound, EarningsPool.Data memory pool) { - BondingCheckpoint memory bond = getBondingCheckpointAt(_transcoder, _round); + BondingCheckpoint storage bond = getBondingCheckpointAt(_transcoder, _round); rewardRound = bond.lastRewardRound; if (rewardRound > 0) {