Fix ram usage so it is provided by voter rather than contract for rewards#17
Merged
Merged
Conversation
There was a problem hiding this comment.
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_tablerow creation invote()to usevoteras the RAM payer. - Update
.husky/pre-committo use/usr/bin/env shand source Husky’s helper script before runninglint-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.emplaceto usevoteras the RAM payer only affects newly created reward rows. For any existing rows that were previously created withget_self()as payer, the subsequentrewards.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 usingvoteras the payer in themodifycalls (here and in other reward updates likeupdate_voter_rewards/claimreward, whererequire_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.