alloy-rs / alloy

Transports, Middleware, and Networks for the Alloy project
https://alloy.rs
Apache License 2.0
667 stars 241 forks source link

JSON-RPC types do not agree with Ethereum's OpenRPC spec #1560

Closed 0xaatif closed 1 month ago

0xaatif commented 1 month ago

As an example, take debug_getBadBlocks (alphabetically, the first method in the spec)

- name: debug_getBadBlocks
  summary: Returns an array of recent bad blocks that the client has seen on the network.
  params: []
  result:
    name: Blocks
    schema:
      title: Bad block array
      type: array
      items:
        $ref: '#/components/schemas/BadBlock'

https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/debug/getters.yaml#L82-L91

BadBlock looks like

BadBlock:
  title: Bad block
  type: object
  required:
    - block
    - hash
    - rlp

https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.4/src/schemas/block.yaml#L140-L146

But in alloy, we return a Vec<Block>: https://github.com/alloy-rs/alloy/blob/b621af07b7bd970d256c523c90ec0c91ec61cea1/crates/provider/src/ext/debug.rs#L30

This is the wrong struct (there's no BadBlock struct anyway)

EdwardJES commented 1 month ago

Keen to take the the BadBlock task.

mattsse commented 1 month ago

cool @EdwardJES for this we need a new helper type and then simply swap out the return type

yash-atreya commented 1 month ago

Closed by #1566