Skip to content
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 decimals in corner cases and use round up #13287

Merged
merged 2 commits into from
May 29, 2024
Merged

fix decimals in corner cases and use round up #13287

merged 2 commits into from
May 29, 2024

Conversation

shileiwill
Copy link
Contributor

@shileiwill shileiwill commented May 22, 2024

Screenshot 2024-05-22 at 6 21 41 PM
This PR is to improve 2 things on payment:

  1. Ensure to use the right decimal scaling in 2 corner cases (balance < gasCharge and balance < gasCharge + premium)
  2. Round it up when we charge. Keep the default round down for NOPs payment. This ensures we get a minimum (1) charge for gas and premium.

Here is a good example of Rounding Errors, text search "Rounding Errors" in the article.


Went through the code paths again. decimal scaling is only in transmit path: more specifically they are in calculatePayment and handlePayment. handlePayment is to handle the 2 special cases which we missed before.

RyanRHall
RyanRHall previously approved these changes May 23, 2024
@@ -44,8 +44,8 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
// Next block of constants are only used in maxPayment estimation during checkUpkeep simulation
// These values are calibrated using hardhat tests which simulate various cases and verify that
// the variables result in accurate estimation
uint256 internal constant REGISTRY_CONDITIONAL_OVERHEAD = 97_700; // Fixed gas overhead for conditional upkeeps
uint256 internal constant REGISTRY_LOG_OVERHEAD = 122_000; // Fixed gas overhead for log upkeeps
uint256 internal constant REGISTRY_CONDITIONAL_OVERHEAD = 97_700 + 500; // Fixed gas overhead for conditional upkeeps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just increase the values here?

@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@shileiwill shileiwill added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
@cl-sonarqube-production
Copy link

@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 29, 2024
@shileiwill shileiwill added this pull request to the merge queue May 29, 2024
Merged via the queue into develop with commit 8491b24 May 29, 2024
112 checks passed
@shileiwill shileiwill deleted the roundup branch May 29, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants