Skip to content

Rollup: Disambiguate JSON encoding for rollup operations

The previous encoding for the rollup operation was ambiguous, and it was notably causing a long standing bug where we couldn’t create a [Tx_only] rollup.

The underlying cause was that, when we were encoding in JSON a contents_list with the following operation:

[Rollup (Create_rollup { kind = Tx_only })]

The resulting JSON was something of the form

{
    ...
    "rollup": {}
}

This was due to the fact that (1) rollup operation encoding did not wrap the payload of an operation in an object, (2) the encoding of the [Create_rollup] was not wrapping its payload in an object, and (3) both [Counter] and [Tx_only] were encoded as [()] ([unit]).

The [tag] field is only used for the binary encoding, which therefore did not suffer this issue. But because the tezos client is using the node to simulate an operation prior to submitting it, and that simulation is triggered through a RPC using the JSON encoding, there were a mismatch because [Create_rollup { kind = Tx_only }] was interpreted as [Create_rollup { kind = Counter }].

With this patch, we fix the various encoding issues uncovered by this investigation. We try to more systematically wrap the encoding of values within an object ([objN]), rather than relying on [tupN] or “transparent” encoding.

Merge request reports