Skip to content

feat: ExpectedRewardForPower builtin utility function #13138

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

Merged
merged 2 commits into from
May 27, 2025

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented May 23, 2025

And lotus-shed miner expected-reward CLI command

Ref: #13137

@Copilot Copilot AI review requested due to automatic review settings May 23, 2025 04:36
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz May 23, 2025
github-actions[bot]

This comment was marked as resolved.

@github-project-automation github-project-automation bot moved this from 📌 Triage to ⌨️ In Progress in FilOz May 23, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the ExpectedRewardForPower builtin utility function and ties it into the CLI via a new "expected-reward" command for miners. Key changes include:

  • Adding the minerExpectedRewardCmd to the CLI commands in cmd/lotus-shed/miner.go.
  • Updating miner-fees-related code to import the required reward package and parse the qapower argument.
  • Implementing the ExpectedRewardForPower function in the miner actor code and updating the actor code template to support actor versions ≥13.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cmd/lotus-shed/miner.go Added new CLI command for expected reward computation
cmd/lotus-shed/miner-fees.go Updated imports and added logic for the new CLI command
chain/actors/builtin/miner/miner.go Added ExpectedRewardForPower utility function supporting multiple versions
chain/actors/builtin/miner/actor.go.template Updated template to utilize the new ExpectedRewardForPower function

@rvagg rvagg force-pushed the rvagg/expected-reward-for-power branch from 9996fa5 to 47d0bc5 Compare May 23, 2025 04:44
@rvagg rvagg changed the title feat: ExpectedRewardForPower builtin utility function feat: ExpectedRewardForPower builtin utility function May 23, 2025
@github-actions github-actions bot dismissed their stale review May 23, 2025 04:45

PR title now matches the required format.

@rvagg rvagg force-pushed the rvagg/expected-reward-for-power branch from 47d0bc5 to f6ae68e Compare May 23, 2025 04:48
@rvagg rvagg requested a review from Copilot May 23, 2025 04:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new ExpectedRewardForPower utility in the miner actor package and exposes it via a lotus-shed miner expected-reward CLI command to project miner rewards over a given epoch window.

  • Introduce ExpectedRewardForPower function with version‐aware dispatch in chain/actors/builtin/miner
  • Add miner expected-reward CLI command in cmd/lotus-shed/miner-fees.go and register it in miner.go
  • Update actor code template and changelog

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/lotus-shed/miner.go Registered minerExpectedRewardCmd under the miner commands
cmd/lotus-shed/miner-fees.go Implemented the expected-reward command and tipset/flag parsing
chain/actors/builtin/miner/miner.go Added ExpectedRewardForPower utility with version switch
chain/actors/builtin/miner/actor.go.template Updated template to generate ExpectedRewardForPower for v13+
CHANGELOG.md Documented the new utility and CLI command
Comments suppressed due to low confidence (2)

chain/actors/builtin/miner/miner.go:488

  • No unit tests were added for ExpectedRewardForPower; consider adding tests that cover multiple network versions and edge cases to prevent regressions.
func ExpectedRewardForPower(

cmd/lotus-shed/miner-fees.go:676

  • [nitpick] The variable name rew is ambiguous; renaming it to expectedReward would improve clarity.
rew, err := minertypes.ExpectedRewardForPower(nv, rewardSmoothed, powerSmoothed, qapower, projectionPeriod)

@rvagg rvagg force-pushed the rvagg/expected-reward-for-power branch from f6ae68e to 98d8505 Compare May 23, 2025 04:55
@rvagg
Copy link
Member Author

rvagg commented May 23, 2025

$ lotus-shed miner expected-reward --help
NAME:
   lotus-shed miner expected-reward - Calculate the expected block reward for a miner over a specified projection period (e.g. lotus-shed miner expected-reward --tipset @head --projection-period 1025280 --qapower 69793218560)

USAGE:
   lotus-shed miner expected-reward [command options]

OPTIONS:
   --tipset value             tipset or height (@X or @head for latest) (default: "@head")
   --projection-period value  number of epochs to project reward for (default: 2880)
   --qapower value            Quality Adjusted Power in bytes (default: 34359738368)
   --help, -h                 show help
$ lotus-shed miner expected-reward
Expected reward for 34359738368 bytes of QA power @ epoch 4988993 for 2880 epochs: 111843816440699 attoFIL
$ lotus-shed miner expected-reward --tipset @head --projection-period 1025280 --qapower 69793218560
Expected reward for 69793218560 bytes of QA power @ epoch 4988993 for 1025280 epochs: 63927803959250660 attoFIL

@rvagg rvagg mentioned this pull request May 23, 2025
9 tasks
@rvagg rvagg requested a review from rjan90 May 23, 2025 04:58
@github-project-automation github-project-automation bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FilOz May 23, 2025
And `lotus-shed miner expected-reward` CLI command

Ref: #13137
@rvagg rvagg force-pushed the rvagg/expected-reward-for-power branch from 98d8505 to 1d295f4 Compare May 26, 2025 01:59
@BigLep
Copy link
Member

BigLep commented May 27, 2025

@rvagg : I assume you'll merge?

@rvagg rvagg enabled auto-merge (squash) May 27, 2025 09:30
@rvagg rvagg merged commit 29a3d42 into master May 27, 2025
94 of 96 checks passed
@rvagg rvagg deleted the rvagg/expected-reward-for-power branch May 27, 2025 09:34
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🎉 Done
Development

Successfully merging this pull request may close these issues.

3 participants