-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: forester: do not retry on not eligible slots #1089
feat: forester: do not retry on not eligible slots #1089
Conversation
forester/src/epoch_manager.rs
Outdated
); | ||
return Err(e); | ||
} | ||
let delay = BASE_RETRY_DELAY * 2u32.pow(retries as u32); |
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.
theoretic nit: could use saturating_pow to prevent overflows. anyway don't think it's important because retrys are not gonna overflow in practice
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.
Fixed.
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.
lgtm!
} | ||
} | ||
} | ||
Err(ForesterError::NotEligible) => { |
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.
Nice, are there other errors that we need to handle?
For example, edge cases changing epochs before start or after it has ended (might be covered haven't checked).
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.
Yes, there are still many places in forester where I use ForesterError::Custom(String) generic errors, I should definitely use less generic errors for the specific cases. It's on my list.
…ted the eligibility check to return this error and handle it appropriately during the transaction processing loop.
33fe10e
to
a00f1b4
Compare
Modified the retry delay calculation by using `saturating_mul` and `saturating_pow` to avoid potential overflow issues. This ensures the application remains stable even if the retry count becomes excessively high.
Introduced a new error variant
NotEligible
inForesterError
.Updated the eligibility check to return this error and handle it appropriately during the transaction processing loop.