paritytech / substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.

Home Page:https://paritytech.github.io/substrate-api-sidecar/dist/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`/accounts/{account-id}/staking-payouts`returning duplicated payouts for some nominators

bee344 opened this issue · comments

Description

In some very specific cases, when the nominator nominated the same account more than once on the same era, querying /accounts/{account-id}/staking-payouts will result in an erroneous response by returning duplicated payouts. As it stands now, sidecar will only take one amount staked as the input to calculate the payout and ignore all the others, and return the same payout for every nomination of that validator. This causes these payouts to be inaccurate, since:

  1. It only returns the payout corresponding to a single staked amount, and
  2. It returns that same payout several times, as if the nominator was paid that amount multiple times, even though it's not the case.

This behavior is caused by this specific line since it isn't thought for cases where a validator appears more than once in the nominated list.

Possible solutions

  • Add the 2 (or more) stakes, in order to calculate the payout based on the sum and have only one entry per validator.
  • Calculate the payout for every nominator's stake and still have multiple entries of the same validator but with different payout amounts.