-
Notifications
You must be signed in to change notification settings - Fork 143
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: address inconsistent parameter and mapping order (OZ N-05) #1034
Conversation
Did not address:
|
fix: address inconsistent parameter and mapping order (OZ N-05)
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
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.
We should also update isAuthorized()
external function, and probably in the tests/
folder there are cases where we call this function and we need to switch the param order as well. For example:
contracts/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol
Line 758 in 95b3f83
bool beforeOperatorAllowedGetter = staking.isAuthorized(operator, msgSender, verifier); |
Presumably this would also imply updating the relative ordering of many other things too, for example: contracts/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol Line 757 in 95b3f83
contracts/packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol Line 881 in 95b3f83
Proposed consistent order: |
531a9c7
to
7be3c85
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## horizon #1034 +/- ##
========================================
Coverage 92.51% 92.51%
========================================
Files 46 46
Lines 2392 2392
Branches 428 428
========================================
Hits 2213 2213
Misses 179 179
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Yes good idea being consistent. I wouldn't mind keeping |
New Proposed consistent order after discussions with Pablo: (ServiceProvider, Operator, Verifier) |
8a5b876
to
edc5c3e
Compare
Hey @MoonBoi9001 @pcarranzav curious why you chose |
I don't feel strongly about it, but to me it made intuitive sense that:
But if you think the other ordering is cleaner I'm happy with that too; but would prefer if the "transitiveness" was enforced, e.g. setOperator and setOperatorLocked should be changed to (verifier, operator, allowed) as well |
I see. I think I still prefer to keep the (serviceProvider, verifier, ...) pattern, I feel like it's easier to remember, but I do agree we need to change SetOperator and SetOperatorLocked as well to enforce the transitiveness. |
I'm happy with that, @MoonBoi9001 sorry for the churn, how do you feel about changing it to (serviceProvider, verifier, operator) and checking it's transitively consistent everywhere? |
Okay, will do that. |
aa8a4b6
to
b7a3ddb
Compare
…ager.sol Co-authored-by: Tomás Migone <[email protected]>
b7a3ddb
to
0f1522d
Compare
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.
Looks great 👍
thanks @MoonBoi9001 and sorry for the trouble 👍 |
Motivation:
Title:
N-05 Inconsistent Parameter and Mapping Order
Details:
In the HorizonStaking contract, the _isAuthorized function has the following parameter order: _operator, _serviceProvider, _verifier. On the other hand, the _operatorAuth mapping uses this order: _serviceProvider, _verifier, _operator. In addition, the _legacyOperatorAuth variable is defined as a mapping from an operator to a service provider to a boolean status. However, it is being used as a mapping from a service provider to an operator to a boolean status.
These inconsistencies can lead to confusion and potential errors during integration or modification, as developers may misinterpret the correct parameter order.
Consider aligning the parameter order in both the _isAuthorized function and the _operatorAuth mapping for improved consistency. Moreover, consider updating the keys and value names in the _legacyOperatorAuth mapping definition to match its usage.
Key changes:
Consistent peramater order:
ServiceProvider, Verifier, Operator