-
Notifications
You must be signed in to change notification settings - Fork 73
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: calculation should be UTC now instead of executor's now #397
fix: calculation should be UTC now instead of executor's now #397
Conversation
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 good, functionally, but I wonder about us doing date math on behalf of the user as there are some non-intuitive cases depending on the timezone of the caller, and if they pass '0' it will create an expiration date at the end of the prior month I think. Is it an absolute requirement that the quotas must be set to expire at UTC midnight specifically, from the systems perspective? If I'm running a service outside of UTC, this seems very awkward for me. Just for my info -- is there a technical limitation/reason why we don't just let the consumer of this API pass us an explicit timestamp and leave the date math logic up to them?
Yea, the crypto world (ethereum, and all chains) runs on UTC so it's an absolute requirement, that's why the parameter is specifically named to |
I understand that the For example, if I want to set a quota that expires at midnight in my or my end-user's local timezone, and they or I am in UTC -2, then I would want to set the expiration timestamp to UTC 0200 instead of 0000; otherwise it would expire at 10PM in my or my user's timezone which may surprise them or me. To re-phrase, Did we arbitrarily choose that all expirations will happen at midnight in the UTC timezone, and only provide an API that forces the users to define their expirations that way, or is it a technical requirement that all expirations will happen at midnight in the UTC timezone? |
Just for later reference: UTC expirations are enforced at the smart contract logic-level so this is a technical requirement currently (the smart contract will throw an error if you set an expiresAt to anything other than midnight on a particular date) -- ref: https://github.com/LIT-Protocol/lit-assets/blob/60c4144d24cf49e9cee6c65d08a052ea5df34290/blockchain/contracts/contracts/lit-node/RateLimitNFT/RateLimitNFTFacet.sol#L169-L172 Thanks for the info @Ansonhkg :) |
Description
This PR addresses an issue in the
calculateUTCMidnightExpiration
function, where calculations for expiration timestamps were inaccurately computed for users in timezones ahead of UTC. Specifically, when attempting to calculate the expiration timestamp with a parameter likedaysUntilUTCMidnightExpiration: 1
, the result would inaccurately represent less than 24 hours until expiration due to the discrepancy between local and UTC times.Type of change
How Has This Been Tested?
minting rli with 1 day expiration
Checklist: