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 16, 2023
1 parent ec801e2 commit 5a0e783
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 @@ -330,7 +330,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 @@ -355,7 +355,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 @@ -364,7 +368,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 Down Expand Up @@ -392,7 +396,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 = getTranscoderEarningPoolForRound(
bond.delegateAddress,
bond.lastClaimRound
Expand Down Expand Up @@ -433,7 +441,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;

// only fetch pool if there is a previous reward() call recorded
Expand Down

0 comments on commit 5a0e783

Please sign in to comment.