Skip to content

Commit

Permalink
Revert "bonding: Use memory instead of storage for checkpoints"
Browse files Browse the repository at this point in the history
This reverts commit ec801e2.
  • Loading branch information
victorges committed Aug 17, 2023
1 parent e74f3a4 commit 8f079ff
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions contracts/bonding/BondingVotes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8f079ff

Please sign in to comment.