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

RPC: rewards, return error if epoch_boundary_block is a lie #2758

Merged

Conversation

CriesofCarrots
Copy link

Problem

In getInflationReward, the epoch_boundary_block determined here may not actually be the epoch boundary block. This can happen if there is a gap in the ledger or long-term storage followed by finalized blocks.
In such a case, it will be impossible to find any rewards.

Summary of Changes

Check the parent slot of epoch_boundary_block; if it is not smaller than the known first_slot_in_epoch, epoch_boundary_block is a lie. Return a custom RPC error in this case, pointing to server-side issues.

Copy link

mergify bot commented Aug 27, 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 @CriesofCarrots.

@CriesofCarrots CriesofCarrots added the v2.0 Backport to v2.0 branch label Aug 27, 2024
Copy link

mergify bot commented Aug 27, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

t-nelson
t-nelson previously approved these changes Aug 28, 2024
Copy link

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

logic lgtm. left one error message clarifying nit that you can take or leave

rpc-client-api/src/custom_error.rs Outdated Show resolved Hide resolved
Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>
@CriesofCarrots CriesofCarrots merged commit 9a4b094 into anza-xyz:master Aug 28, 2024
40 checks passed
mergify bot pushed a commit that referenced this pull request Aug 28, 2024
* Return error if epoch_boundary_block is not actually the epoch boundary block

* Update rpc-client-api/src/custom_error.rs

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>

---------

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>
(cherry picked from commit 9a4b094)
Copy link

mergify bot commented Aug 28, 2024

Backports to the stable branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule.

mergify bot pushed a commit that referenced this pull request Aug 28, 2024
* Return error if epoch_boundary_block is not actually the epoch boundary block

* Update rpc-client-api/src/custom_error.rs

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>

---------

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>
(cherry picked from commit 9a4b094)

# Conflicts:
#	rpc-client-api/src/custom_error.rs
#	rpc/src/rpc.rs
CriesofCarrots added a commit that referenced this pull request Aug 30, 2024
…ckport of #2758) (#2767)

RPC: rewards, return error if epoch_boundary_block is a lie (#2758)

* Return error if epoch_boundary_block is not actually the epoch boundary block

* Update rpc-client-api/src/custom_error.rs

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>

---------

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>
(cherry picked from commit 9a4b094)

Co-authored-by: Tyera <tyera@anza.xyz>
CriesofCarrots added a commit that referenced this pull request Aug 30, 2024
…ackport of #2758) (#2781)

* RPC: rewards, return error if epoch_boundary_block is a lie (#2758)

* Return error if epoch_boundary_block is not actually the epoch boundary block

* Update rpc-client-api/src/custom_error.rs

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>

---------

Co-authored-by: Trent Nelson <490004+t-nelson@users.noreply.github.com>
(cherry picked from commit 9a4b094)

# Conflicts:
#	rpc-client-api/src/custom_error.rs
#	rpc/src/rpc.rs

* Fix conflicts

---------

Co-authored-by: Tyera <tyera@anza.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.18 v2.0 Backport to v2.0 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants