-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bug fix: Limiting Number of Sponsorship Calls for New Users #52
Conversation
7d31423
to
b9422ea
Compare
b9422ea
to
24b36b8
Compare
24b36b8
to
d706308
Compare
c53ec0f
to
fd247d2
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.
I haven't tried due to mysterious, but hopefully temporary, technical reasons. However, there's no way this code works. Can you please describe how you tested it?
d87a0d7
to
30b4742
Compare
9e0df0e
to
2cc8de0
Compare
…dress, add user_id tie to contract_id
624cdb9
to
ccc3ae2
Compare
…t for 4 newest users
…tie to contract_id
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.
This does not seem correct at all, for various reasons.
sponsee_address: str | ||
class MaxCallsPerContractForNewUsersCondition(ConditionBase): | ||
contract_id: UUID4 | ||
user_id: UUID4 |
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.
Why did you add this?
recent_users: List[models.User] = ( | ||
db.query(models.User) | ||
.order_by(models.User.created_at.desc()) | ||
.limit(4) |
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.
What? Why such an arbitrary limit?
if not entrypoint.is_enabled: | ||
raise EntrypointDisabled() | ||
|
||
# Retrieving the user_id |
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.
In this context, it's not clear who you call "the user". According to what you write just after, it seems to be the user who added the contract; however, you're also testing if the user is "new" (for some definition of "new", but whatever), which, I suspect, is your way of translating the real-world example I gave you. In this example, I was giving you the idea that we needed to change the "max calls per user" condition so that it can be used to limit the activity of some users without impacting newer users, but your translation of this requirement seems rather fanciful.
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.
The general idea is that, in the context of this issue/PR, a user should not be considered "new" because of the age of their account, but rather because of their recent activity relatively to the sponsored contract.
However, when we talk about "user" in this context, we're definitely talking about end-users, or sponsees (users whose transactions are paid for by the API) and not contracts' owners.
user = crud.get_user_by_address(db, owner_address) | ||
user_id = user.id | ||
if not crud.check_user_is_new(db, user_id.id): | ||
raise UserNotFound() |
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.
So… if the user is not new, you're simply refusing the operation, regardless of the condition?
d42eb26
to
35e11bf
Compare
Git Issue #45: Limiting Number of Sponsorship Calls for New Users
Description:
Currently, there exists a manual limitation on the number of calls for a specific sponsee (giving their address and so on).
However, the correct condition should be to set a maximum limit on a number of calls from any address or new user, without having to manually enter them one by one. This ensures that only the first N calls are sponsored for each user.
sponsee_address
in condition