Skip to content

Lodestar can not parse non-hex string validator_index in getStateValidatorBalances #7881

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

Open
Alleysira opened this issue May 27, 2025 · 0 comments · May be fixed by #7951
Open

Lodestar can not parse non-hex string validator_index in getStateValidatorBalances #7881

Alleysira opened this issue May 27, 2025 · 0 comments · May be fixed by #7951
Labels
meta-bug Issues that identify a bug and require a fix. scope-api Issues related to APIs

Comments

@Alleysira
Copy link

Hello Lodestar team,

I’ve encountered a potential inconsistency with how Lodestar handles validator_balances requests.

According to the beacon-API specification, the id parameter can be a validator index represented as a string (e.g., "22710") or a hex-encoded public key. However, when making the following request:

curl -X GET http://localhost:4000/eth/v1/beacon/states/head/validator_balances?id=22710

The differential testing results show that only lodestar return error

{"code":500,"message":"hex string length 5 must be multiple of 2"} # lodestar
{"data": [], "execution_optimistic": false, "finalized": false} # prysm
{"data": [], "execution_optimistic": false, "finalized": false} # lighthouse
{"data": [], "execution_optimistic": false, "finalized": false} # teku
{"data": [], "execution_optimistic": false, "finalized": false} # nimbus
{"data": [], "execution_optimistic": false, "finalized": false} # grandine

Schema:

{
  "name": "id",
  "description": "Either hex encoded public key (any bytes48 with 0x prefix) or validator index",
  "in": "query",
  "required": false,
  "schema": {
    "type": "array",
    "maxItems": 64,
    "uniqueItems": true,
    "items": {
      "description": "Either hex encoded public key (any bytes48 with 0x prefix) or validator index",
      "type": "string"
    }
  }
}

Related code implementation in lodestar:

if (typeof id === "number") {
if (state.validators.length <= id) {
continue;
}
balances.push({index: id, balance: state.balances.get(id)});
} else {
const index = headState.epochCtx.pubkey2index.get(fromHex(id));
if (index != null && index <= state.validators.length) {
balances.push({index, balance: state.balances.get(index)});
}

Thanks for your time!

@nflaig nflaig added the meta-bug Issues that identify a bug and require a fix. label May 27, 2025
@philknows philknows added the scope-api Issues related to APIs label Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-bug Issues that identify a bug and require a fix. scope-api Issues related to APIs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants