Closed purcell closed 3 years ago
This sounds sensible. You missed two important ones IMO :
* decurryfy all functions
There's actually a Ligo merge request in the works that makes this unnecessary, at least as long as code isn't explicitly placed in modules (which are now preliminarily supported), so we've taken this into account in our planning.
do not use continuations to make functions tail recursive, use an explicit data structure instead like a list representing the argument stack
And we already have followed this through, sorry I forgot to post an update to the channel. Now we don't use continuations on avl
. I remember that change saving around 25% of generated Michelson.
Open issue: Ligo has no mechanism for originating a new contract, yet Checker will need to originate Burrow contracts. How will we do this? Presumably we will drop down to michelson for this.
To do next:
Tezos.transaction
Tezos.create_contract
(see here)main
and a sum type of entrypoints (see here) - maybe do this early to see more generated Michelson earliermake build-ligo
now succeeds with all entrypoints being reachable, so I think we can safely close this one.
Goals
Proposed approach
Write Ocaml that approaches Ligo, with shims
Code that is to be included in the target contract is written in Ocaml, in a particular style:
.foo
accesses, which can lead to multiple unpacking of data (citation needed!)_
as an identifier or wildcard in patterns, avoid'
suffixes~keyword
argsint
,big_map
,list
,mutez
, with that module corresponding to the "top-level" module in Ligo itself.LigoBig_map
,LigoString
,LigoList
,LigoMap
,LigoTezos
etc., and qualify the names fully (we will write whichever of these modules we need to use). See https://ligolang.org/docs/reference/current-referenceediv_mutez_nat
etc. instead ofediv
variantsfailwith
variantsadd_nat_mutez
etc. for basic arithmeticLigoXXX
modules may expose some functions that facilitate testing, e.g. unwrap Ligo lists/strings as the ocaml equivalents, or set the active balance forLigoTezos
.Process for translation to Ligo
As an automated process, produce Ligo from Ocaml and build it with the Ligo tools, following these conversion steps:
open
with#include
Ligo.
prefix for qualified identifiersLigo
prefix for remaining qualified identifiers, ie.LigoString.foo
=>String.foo
@inline
directives meant for Ligo (and, in general, any code somehow marked as "ligo only", if we do that)ediv_xxx
variants with justediv
failwith
variants with justfailwith
@inline
-d arithmetic functions that just defer to builtinsInitial code changes necessary:
Ratio
/FixedPoint
/Tez
/Nat
in terms ofLigo
module's types, or remove entirely as appropriateTezos
as a param, instead mutateLigoTezos
globals using ocaml-only backdoor functions provided for testing purposes, e.g. to changenow