filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.83k stars 1.26k forks source link

[DX Streamline] OpenRPC definitions are inaccurate #12164

Open aatifsyed opened 3 months ago

aatifsyed commented 3 months ago

Checklist

Lotus component

Lotus Version

1.27.1

Repro Steps

No response

Describe the Bug

https://github.com/filecoin-project/lotus/blob/36d96342c36186ab15417b53511dce94b66ae089/build/openrpc/full.json#L71-L91

The schema for, e.g cid is wrong - it's not

{
  "type": "string"
}

it's

{
  "type": "object",
  "required": ["/"],
  "properties": {
    "/": { "type": "string" }
  }
}

(as expected and emitted by lotus)

Logging Information

N/A
aatifsyed commented 3 months ago

There may be other bugs in the definitions - forest has put effort into emitting correct schemas which may be a useful reference

rvagg commented 3 months ago

Great! Thanks for this one.

What about the use of TipSetKey, they seem to be "type": ["object"] but could be defined as an array of CIDs, does Forest do this differently?

aatifsyed commented 3 months ago

Yep, forest represents them correctly, also respecting the quirk that empty arrays are serialized as null by Lotus

{
  "type": [
    "array",
    "null"
  ],
  "items": {
    "$ref": "#/components/schemas/Cid"
  },
  "components": {
    "schemas": {
      "Cid": {
        "type": "object",
        "required": [
          "/"
        ],
        "properties": {
          "/": {
            "type": "string"
          }
        }
      }
    }
  }
}
aatifsyed commented 2 months ago