New instructions for comb pairs
Clarification and motivation
They added:
- New instructions PAIR n, UNPAIR n, GET 2k+b, UPDATE 2k+b to respectively build a comb pair of size n from n stack elements, decompose a comb pair of size n into n stack elements, access the k -th element in a comb pair, replace the k -th element in a comb pair.
- Optimized notations for comb pair types and values (like
Pair a b c
and{a; b; c}
).
- plus
GET_AND_UPDATE
was added.
The latter two instructions from the first point:
- should probably look in Michelson as
GETN
andUPDATEN
. - if we add them in Lorentz, let's call them completely differently like
tupleGet
andtupleUpdate
.
Though we need to think thoroughly whether is it worth adding those to Lorentz. We already have methods for working with product types, but new instructions are different - they are probably more optimal, but work only for right-hand combs. I think we should not touch the existing instructions nor add new ones in Lorentz and rather find a way to add a rules to replace toField -> GET
in optimizer. This way all our code, not only specific methods, will benefit from new instructions. This way we also won't need to update the existing abstraction levels like StoreClass.hs
or tuples with named fields (("a" :! T1, "b" :! T2)
) - we probably don't want to add additional implementations of all those on the comb manner.
Acceptance criteria
- Implement these in Michelson.
- Think how to propagate them in Lorentz and implement (most probably - add optimization rules).
- RPC decoder is updated to handle new pairs representation.
- When converting typed contract to untyped contract - detect combs pairs in types and replace them with optimizied
pair a b c
notation - to improve contract size and readability. - Consider using
GET_AND_UPDATE
for*insertNew
methods.