fix RPCs versioning mechanism
Context
This MR fix a flaw in the versioning mechanism. This flaw makes it impossible for a service running on master to decode binary RPC answers from a node running v17*.
In !8891 (merged) !9008 (merged) !8980 (merged) !8960 (merged) we have introduced a mechanism to version rpcs. This mechanism is based on a Data_encoding union between two different encodings allowing the RPC to output two different JSON according to the version chosen.
The union changed the RPC answer from <result> to version,<result>. These changes were not discovered earlier because the version is not output in JSON but they add starting bytes in the binary output, breaking retro compatibility.
This MR reworked this mechanism by using Data_encoding.splitted to have a different encoding in binary and JSON.
This MR replace !9410 (closed)
Manually testing the MR
On master I run
./octez-client gen keys albin
./octez-baker-PtNairob -E https://rpc.nairobinet.teztnets.xyz run remotely albin --liquidity-baking-toggle-vote pass
https://rpc.nairobinet.teztnets.xyz run a node on v17*
And I got:
Node is bootstrapped.
Waiting for protocol 017-PtNairob to start...
Baker v0.0+dev (0cc9cad6) for PtNairobiyss started.
Jul 05 22:29:28.859: error while monitoring heads
Jul 05 22:29:28.859: Error:
Jul 05 22:29:28.859: Rpc request failed:
Jul 05 22:29:28.859: - meth: GET
Jul 05 22:29:28.859: - uri: https://rpc.nairobinet.teztnets.xyz/chains/main/blocks/BLveNaeNpf2UXxxvML1sT1Thuwet9iKGp25xkD6LkECAtZbx8on/operations?version=0
Jul 05 22:29:28.859: - error: Failed to parse the answer (application/octet-stream):
Jul 05 22:29:28.859: error:
Jul 05 22:29:28.859: Failed to parse binary data: Not enough data.
Jul 05 22:29:28.859: content:
Jul 05 22:29:28.859: "\000\000\021\157\000\000\021\153\000\000\021}\000\000\021y\244\154\249[\223\023\195\130c\138-G6\011\188\219;\157\0231\b\238\194\151\018\"\137\019\169\151\193r\176J\244\128\000\000\000 \1575\171\017=D\0022\025+S\1
It fails as expected because the baker expect an additional starting byte.
With the current branch:
Node is bootstrapped.
Waiting for protocol 017-PtNairob to start...
Baker v0.0+dev (6600044f) for PtNairobiyss started.
Jul 05 22:32:03.930: received new head BLQTyJyQXuoCChrfNz12SaAeVLjAHBdqnY3kAo2kTUdWZxnZDVB at
Jul 05 22:32:03.930: level 730193, round 0
CI Green for other tests
Checklist
- n/a Document the interface of any function added or modified (see the coding guidelines)
- n/a Document any change to the user interface, including configuration parameters (see node configuration)
- n/a Provide automatic testing (see the testing guide).
- n/a For new features and bug fixes, add an item in the appropriate changelog (
docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR