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

Predict when the next reward will be farmed #206

Closed
wants to merge 7 commits into from
Closed

Conversation

abhi3700
Copy link

@abhi3700 abhi3700 commented May 30, 2024

Background

The issue titled "Predict when the next reward will be farmed" discusses the potential to provide users (farmers) with predictions on when they can expect to receive rewards based on on-chain data regarding space pledged and the last farming reward payment timestamp. This prediction could then be displayed to the user as having a high/low probability of receiving a reward with descriptions like "today", "in about an hour", or "any time now".

Description

This PR adds:

  • circular progress bar widget to show the next reward ETA (in sec, min, hr, day, week).
  • function to calculate total space pledged based on retrieved fields - slot_probability (from frontend), current_solution_range, max_pieces_in_sector (from backend).
  • calculate_expected_reward_duration_from_now function to calculate the ETA for next reward payment.

A test code snippet is present in the code (commented) to see how it works. Just uncomment to test it by toggling FarmDetails button.

abhi3700 added 4 commits May 30, 2024 13:06
- This is a probabilistic function based on the amount of space pledged by farmer w.r.t the total space pledged. Also considered the last reward timestamp to give an idea as to when can a farmer expect the next reward.
- Boxed the large field `raw_config to reduce the total size of the enum. Suppressed `#[warn(clippy::large_enum_variant)]` warning.
- Add the widget drawn using DrawingArea object considering its suitable appearance in both light & dark themes.
- Implement that in Relm4 code style.
- Integrated the widget into RunningView frontend page.
- Also added a testing feature to try how it works by toggling the FarmDetails button.
- Commented the test button logic to see how the progress bar works.
- Total space pledged function added to backend so as to calculate it fetching the TSP metrics.
@abhi3700 abhi3700 added enhancement New feature or request farmer Farmer functionality labels May 30, 2024
@abhi3700 abhi3700 self-assigned this May 30, 2024
@abhi3700 abhi3700 requested a review from nazar-pc May 30, 2024 09:48
@abhi3700 abhi3700 linked an issue May 30, 2024 that may be closed by this pull request
Copy link
Member

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

Some comments are minor and stylistic, some are more significant. Can discuss synchronously if needed.

src/backend/farmer.rs Outdated Show resolved Hide resolved
src/backend/farmer.rs Outdated Show resolved Hide resolved
src/backend/farmer.rs Outdated Show resolved Hide resolved
src/backend/farmer.rs Outdated Show resolved Hide resolved
src/backend/node.rs Outdated Show resolved Hide resolved
src/frontend/running.rs Outdated Show resolved Hide resolved
src/frontend/running.rs Outdated Show resolved Hide resolved
src/frontend/running.rs Show resolved Hide resolved
src/frontend/running.rs Outdated Show resolved Hide resolved
src/frontend/running.rs Outdated Show resolved Hide resolved
abhi3700 added 2 commits June 7, 2024 02:19
- Rectified tests in test_format_eta function in src/frontend/utils
- Receive chain constants into RunningView FE on each block import via sending separate event.
- Receive space_pledged from backend rather than frontend.
@abhi3700 abhi3700 requested a review from nazar-pc June 7, 2024 22:11
Copy link
Member

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

It is taking way too much time for me to review this PR comparing to just doing it myself at this point. I'll use it as a reference and create another one with correct implementation.

Comment on lines +535 to +536
let (current_solution_range, max_pieces_in_sector) =
consensus_node.total_space_pledged_chain_constants()?;
Copy link
Member

Choose a reason for hiding this comment

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

Neither current solution range nor max pieces in sector are actually constants. And even if they were, it would make much more sense to send all of this in initialization notification instead.

@abhi3700
Copy link
Author

It is taking way too much time for me to review this PR comparing to just doing it myself at this point. I'll use it as a reference and create another one with correct implementation.

Okay.

@nazar-pc
Copy link
Member

Replaced with #230

@nazar-pc nazar-pc closed this Jul 16, 2024
@nazar-pc nazar-pc deleted the fix-issue-86 branch July 16, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request farmer Farmer functionality
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Predict when the next reward will be farmed
2 participants