-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: tips scaling in Summit
#1463
Conversation
WalkthroughThe changes primarily focus on the implementation of a new tipping system in the Summit contract. The system scales up the tip value for better precision and modifies the associated events and tests accordingly. Changes
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1463 +/- ##
===================================================
+ Coverage 50.69210% 50.69407% +0.00197%
===================================================
Files 356 356
Lines 24274 24277 +3
Branches 267 268 +1
===================================================
+ Hits 12305 12307 +2
Misses 10775 10775
- Partials 1194 1195 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (3)
- packages/contracts-core/contracts/Summit.sol (3 hunks)
- packages/contracts-core/contracts/events/SummitEvents.sol (1 hunks)
- packages/contracts-core/test/suite/SummitTips.t.sol (5 hunks)
Files skipped from review due to trivial changes (1)
- packages/contracts-core/contracts/events/SummitEvents.sol
Additional comments (Suppressed): 9
packages/contracts-core/contracts/Summit.sol (3)
4-10: The import statement for
TIPS_GRANULARITY
from./libs/Constants.sol
has been added. Ensure that this constant is defined in theConstants.sol
file and that its value is appropriate for the shift operation in line 335.61-69: The
ActorTips
struct now includes comments for its fieldsearned
andclaimed
. This is a good practice as it improves code readability and understanding.329-338: The
_awardActorTip
function has been modified to scale up the tip value before adding it to theearned
field ofactorTips
. This is done to store the full tip value inactorTips
as opposed to the scaled-down value. TheTipAwarded
event now emits the scaled-up tip value. Ensure that this change is reflected in all parts of the codebase where this event is handled.- actorTips[actor][origin].earned += tip; - emit TipAwarded(actor, origin, tip); + uint128 tipAwarded = uint128(tip) << uint128(TIPS_GRANULARITY); + actorTips[actor][origin].earned += tipAwarded; + emit TipAwarded(actor, origin, tipAwarded);packages/contracts-core/test/suite/SummitTips.t.sol (6)
238-245: The new function
expectAwardedTipsEvents
is called beforedistributeTips
andcheckAwardedTips
. This function seems to simulate the awarding of tips and is expected to generate events that are then checked in thecheckAwardedTips
function. Ensure that this function is working as expected and that it does not interfere with the actual distribution of tips.254-261: Similar to the previous comment, the
expectAwardedTipsEvents
function is called beforedistributeTips
andcheckAwardedTips
. Ensure that this function is working as expected and that it does not interfere with the actual distribution of tips.278-284: Again, the
expectAwardedTipsEvents
function is called beforedistributeTips
andcheckAwardedTips
. Ensure that this function is working as expected and that it does not interfere with the actual distribution of tips.377-408: The function
checkActorTips
has been renamed tocheckEarnedActorTips
and refactored to use a scaled-down version of earned tips, which is then scaled up by2**32
when checking the earned tips. This change is in line with the PR summary and seems to be a necessary adjustment to ensure that actors receive the correct amount of tips. However, ensure that this scaling operation does not introduce any rounding errors or inaccuracies in the calculation of tips.412-425: The function
checkActorTips
has been renamed tocheckEarnedActorTips
and refactored to use a scaled-down version of earned tips, which is then scaled up by2**32
when checking the earned tips. This change is in line with the PR summary and seems to be a necessary adjustment to ensure that actors receive the correct amount of tips. However, ensure that this scaling operation does not introduce any rounding errors or inaccuracies in the calculation of tips.426-504: The new functions
expectAwardedTipsEvents
,expectAwardedTipsEventsFirstSubmit
,expectAwardedTipsEventsReceiptTips
,expectAwardedTipsEventsFinalSubmit
,expectAwardedTipsEvent
, andcheckEarnedActorTips
have been added. These functions seem to simulate the awarding of tips and the generation of events, and then check the earned tips. Ensure that these functions are working as expected and that they do not interfere with the actual distribution of tips. Also, ensure that the scaling operation incheckEarnedActorTips
does not introduce any rounding errors or inaccuracies in the calculation of tips.
|
Description
Fixes a bug where
Summit
was storing actor tip values scaled down by2**32
(as they appear in the message payload). As a result, the actors (bonded agents and unbonded executors) were previously gaining a tiny fraction of the message tips.Summary by CodeRabbit
TipAwarded
event in theSummitEvents
contract to reflect the new tip calculation method.SummitTipsTest
contract with a new function to simulate the awarding of tips and improved existing functions for better accuracy in testing the earned tips of an actor.These changes aim to improve the overall user experience by providing a more precise and transparent system for managing and tracking tips.