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: EpochRewards: decode points and rewards fields as Strings (backport of #2501) #2512

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Aug 8, 2024

Problem

EpochRewards::points can easily overflow the max JSON integer, but we are trying to use serde_json::Number in solana-account-decoder: #760

This results in RPC results that fail JSON parsing, eg:

$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["SysvarEpochRewards1111111111111111111111111",{"encoding":"jsonParsed","commitment":"confirmed"}]}' 127.0.0.1:8899 | jq
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "2.0.3",
      "slot": 475138
    },
    "value": {
      "data": [
        "AUAHAAAAAAApAAAAAAAAAIUNPEmDh+dINbalmdonQUN3ihFWtNs3TkzSdK+Iq7bWAAAtdN6RBR8BAAAAAAAAAIYkzjTLAQAA5yWbrzUAAAAB",
        "base64"
      ],
      "executable": false,
      "lamports": 1454640,
      "owner": "Sysvar1111111111111111111111111111111111111",
      "rentEpoch": 0,
      "space": 81
    }
  },
  "id": 1
}

Summary of Changes

Decode points, distributedRewards, and totalRewards as strings
numPartitions should never overflow as it is capped at 43,200
startingBlockHeight could overflow some day, but there are lots of other decoders passing Slot as a number, so this is a more systemic problem and can/should be addressed in one fell swoop.


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

Decode points and rewards fields as Strings

(cherry picked from commit 605acd1)
@mergify mergify bot requested a review from a team as a code owner August 8, 2024 21:52
@CriesofCarrots
Copy link

Proposing a backport because this is a bug in the EpochRewards sysvar account decoder, which will be instantiated in v2.0. But it's also very low risk, as it only affects account data decoding for RPC nodes.

@CriesofCarrots CriesofCarrots merged commit dca9b88 into v2.0 Aug 9, 2024
39 checks passed
@CriesofCarrots CriesofCarrots deleted the mergify/bp/v2.0/pr-2501 branch August 9, 2024 16:55
@behzadnouri
Copy link

Amazing, so @anza-xyz/backport-reviewers can approve their own backports while our work is indefinitely blocked. This is great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants