paritytech / json-rpc-interface-spec

29 stars 3 forks source link

Unclear what happens in case of duplicate hashes passed to `chainHead_unstable_unpin` #133

Closed tomaka closed 7 months ago

tomaka commented 7 months ago

The text doesn't say what happens if you call chainHead_unstable_unpin and pass the same hash multiple times.

lexnv commented 7 months ago

From the spec: (a) The spec notes that -32801 error is returned when at least one of the block hashes has been unpinned. (b) If this function returns an error, then no block has been unpinned.

My interpretation of this is that we cannot unpin a block twice without generating an error from (a). However, we cannot partially unpin blocks from (b). From this, I would lean towards checking the hashes for duplicates on the server side.

We could then change the spec wrt hashOrHashes: "String or array of unique strings containing..."; to mention the unique expectation of the server. When receiving a duplicate hash in the hashOrHashes param, we could return -32602 is generated if one of the parameters doesn't correspond to the expected type.

Would love to get your thoughts on this 🙏

tomaka commented 7 months ago

Whether to return an error or to simply ignore duplicates is kind of arbitrary, since it's not supposed to happen anyway. The only important thing is that all JSON-RPC servers behave the same way.