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

Does eth_getBalance BlockNumber or Tag or BlockHash need array option closed? #579

Open
m4sterbunny opened this issue Sep 5, 2024 · 0 comments

Comments

@m4sterbunny
Copy link

m4sterbunny commented Sep 5, 2024

This probably impacts 2 schemas:

  1. BlockNumberOrTagOrHash ( )

Proposal:
BlockNumberOrTagOrHash:
title: Block number, tag, or block hash.

type: string

anyOf:

  • title: Block number.
    $ref: '#/components/schemas/uint'
  • title: Block tag.
    $ref: '#/components/schemas/BlockTag'
  • title: Block hash.
    $ref: '#/components/schemas/hash32'
  1. BlockNumberOrTag

Proposal
BlockNumberOrTag:
title: Block number or tag.

type: string

oneOf:

  • title: Block number.
    $ref: '#/components/schemas/uint'
  • title: Block tag.
    $ref: '#/components/schemas/BlockTag'

Scenario for 1:
eth_getBalance has 2 required parameters. This potential issue refers to Block.

- name: Block
  required: true
  schema:
    $ref: '#/components/schemas/BlockNumberOrTagOrHash'

Notice that the schema name suggests that BlockNumber or Tag or BlockHash should be passed, i.e. that oneOf these properties may be passed. However, the schema lays out an anyOf:

BlockNumberOrTagOrHash:
title: Block number, tag, or block hash.
anyOf:
- title: Block number.
$ref: '#/components/schemas/uint'
- title: Block tag.
$ref: '#/components/schemas/BlockTag'
- title: Block hash.
$ref: '#/components/schemas/hash32'

oneOf Validation: According to the JSON Schema specification, oneOf requires that the instance validates against exactly one of the subschemas. If the instance is valid against zero or more than one subschema, it’s considered invalid.
Potential for Overlap: In our case, there could indeed be overlap between the uint (block number) and hash32 (block hash) schemas, as both are strings of hexadecimal characters.

{OK this overlap is the reason for the anyOf -- I think, therefore, that the solution may be to prevent more than one value being sent with type: string. I am assuming that with no type set, it's valid to send an illogical array such as 'latest', 0x3. I think that setting to string will throttle this}

@m4sterbunny m4sterbunny changed the title eth_getBalance is anyOf a typo? Does eth_getBalance BlockNumber or Tag or BlockHash need array option closed? Sep 7, 2024
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

No branches or pull requests

1 participant