Skip to content

Support recursive errors and register Economic_protocol_error to solve "consequence of bad union"

Romain requested to merge nomadic-labs/tezos:romain-mu into master

This MR is a cleaner version of !1376 (closed). See this MR to get a description of the initial problem and how to reproduce it.

The original solution(s) of !1376 (closed) were hackish at best (and actually did not work in all cases). This new MR proposes a new, cleaner approach.

One of the commits introduce a reference to increment a number which is added as a suffix to the name of the error encoding. This is because the error encoding is registered several times (with a growing set of cases), but we cannot register it with the same name. I'm not very happy with this but without this hack, tezos-client rpc get /errors fails with "duplicate definition"… The drawback of this hack is that this RPC returns a weird structure with several error definitions that are mixed between each other. So, while this MR does solve the "consequence of bad union" error, it is still probably not the best implementation. I'm open for ideas to solve this without reworking the JSON encoding library completely.

The Make functor is applied once per protocol, and once for the shell. It is important to use different encoding names for all of them, and we do this. This fixes the above paragraph.

I believe this MR only works because JSON schemas are lazy. Otherwise, they would be generated several times for the same error type with a growing list of errors, and as those generated encodings share the same name it would not work.

Edited by Arvid Jakobsson

Merge request reports