Skip to content

Fix ram usage so it is provided by voter rather than contract for rewards#17

Merged
dallasjohnson merged 1 commit into
mainfrom
fix-ram-usage-for-tokelore-rewards
May 5, 2026
Merged

Fix ram usage so it is provided by voter rather than contract for rewards#17
dallasjohnson merged 1 commit into
mainfrom
fix-ram-usage-for-tokelore-rewards

Conversation

@dallasjohnson

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings May 5, 2026 11:45
@dallasjohnson dallasjohnson changed the title Fix ran usage so it is provided by voter rather than contract for rewards Fix ram usage so it is provided by voter rather than contract for rewards May 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce contract RAM usage by making voters (rather than the contract) pay RAM for newly created reward records, and also updates the Husky pre-commit hook to the standard Husky bootstrap format.

Changes:

  • Switch voter_rewards_table row creation in vote() to use voter as the RAM payer.
  • Update .husky/pre-commit to use /usr/bin/env sh and source Husky’s helper script before running lint-staged.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
contracts/tokelore/tokelore.cpp Makes new voter reward rows charge RAM to the voter instead of the contract.
.husky/pre-commit Aligns the pre-commit hook with standard Husky initialization before invoking lint-staged.
Comments suppressed due to low confidence (1)

contracts/tokelore/tokelore.cpp:333

  • Changing rewards.emplace to use voter as the RAM payer only affects newly created reward rows. For any existing rows that were previously created with get_self() as payer, the subsequent rewards.modify(..., same_payer, ...) will keep the contract paying RAM indefinitely, so the PR’s goal (“RAM provided by voter”) won’t be fully achieved for existing voters. Consider using voter as the payer in the modify calls (here and in other reward updates like update_voter_rewards / claimreward, where require_auth(voter) is already enforced) or add a migration path to shift RAM to the voter.
        rewards.emplace(voter, [&](voter_reward_info &r) {
            r.voter              = voter;
            r.vp_participating   = vote_power.amount;
            r.reward_per_vp_paid = current_reward_globals.reward_per_vp_stored;
            r.rewards_accrued    = 0;
        });
    } else {
        rewards.modify(reward_entry, same_payer, [&](voter_reward_info &r) {
            r.vp_participating += vote_power.amount;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dallasjohnson dallasjohnson merged commit 655802e into main May 5, 2026
5 checks passed
@dallasjohnson dallasjohnson deleted the fix-ram-usage-for-tokelore-rewards branch May 5, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants