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

v2.0: SIMD-0118: fix total_rewards for recalculation (backport of #2780) #2794

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Aug 30, 2024

Problem

A node that reboots from a snapshot that was created during the partitioned epoch reward period may diverge from the cluster. This is because the total rewards value currently stashed in the EpochRewards sysvar and used to populate PointValue in recalculation is the total lamports to actually be distributed:

total_rewards: validator_rewards_paid + total_stake_rewards_lamports,

rewards: epoch_rewards_sysvar.total_rewards,

In the initial calculation, however, this part of the PointValue is the total lamports available to be split/distributed. In a cluster with a diverse collection of stake accounts (like testnet), the lamports actually distributed is likely to be less than what is available, due to rounding to whole lamports. Different PointValue::rewards values may yield different calculated rewards.

Summary of Changes

Populate EpochRewards::total_rewards from the calculated PointValue::rewards


This is an automatic backport of pull request #2780 done by [Mergify](https://mergify.com).

* Add new feature key

* Wrap existing code with new feature

* Extend test harness

* Make test fail

* Populate EpochRewards::total_rewards from PointValue

* Remove superfluous struct field

* Fixup tests

(cherry picked from commit 4470f6d)

# Conflicts:
#	programs/bpf_loader/src/syscalls/mod.rs
#	sdk/src/feature_set.rs
@mergify mergify bot requested a review from a team as a code owner August 30, 2024 03:08
@mergify mergify bot added the conflicts label Aug 30, 2024
Copy link
Author

mergify bot commented Aug 30, 2024

Cherry-pick of 4470f6d has failed:

On branch mergify/bp/v2.0/pr-2780
Your branch is up to date with 'origin/v2.0'.

You are currently cherry-picking commit 4470f6d96e.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   programs/stake/src/stake_instruction.rs
	modified:   rpc/src/rpc.rs
	modified:   runtime/src/bank/partitioned_epoch_rewards/calculation.rs
	modified:   runtime/src/bank/partitioned_epoch_rewards/distribution.rs
	modified:   runtime/src/bank/partitioned_epoch_rewards/mod.rs
	modified:   runtime/src/bank/partitioned_epoch_rewards/sysvar.rs
	modified:   runtime/src/bank/sysvar_cache.rs
	modified:   sdk/program/src/epoch_rewards.rs

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   programs/bpf_loader/src/syscalls/mod.rs
	both modified:   sdk/src/feature_set.rs

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Author

mergify bot commented Aug 30, 2024

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/web3.js (example)

Thank you for keeping the RPC clients in sync with the server API @mergify[bot].

Copy link
Author

mergify bot commented Aug 30, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@CriesofCarrots
Copy link

This backport fixes a bug in partitioned epoch rewards that is currently affecting testnet; it is necessary for further rollout of the partitioned epoch rewards feature.

@CriesofCarrots CriesofCarrots merged commit a829dea into v2.0 Sep 3, 2024
39 checks passed
@CriesofCarrots CriesofCarrots deleted the mergify/bp/v2.0/pr-2780 branch September 3, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants