1
1
mirror of https://github.com/anoma/juvix.git synced 2024-10-26 09:45:47 +03:00
Juvix empowers developers to write code in a high-level, functional language, compile it to gas-efficient output VM instructions, and formally verify the safety of their contracts prior to deployment and execution.
Go to file
Paul Cadman b981405e45
Support compilation of Anoma transactions in nockma backend (#2693)
When we first implemented the Nockma backend we wrongly assumed that the
only entry point for Juvix compiled Nockma modules would be the main
function. Using this assumption we could add a setup step in the main
function that put the Anoma stdlib and compiled functions from the Juvix
module in a static place in the Nockma subject. References to the Anoma
stdlib and functions in the module could then be resolved statically.

However, one of the use cases for Juvix -> Nockma compilation is for
Anoma to run logic functions that are fields of a transaction. So the
user writes a Juvix program with main function that returns a
transaction. The result of the main function is passed to Anoma. When
Anoma calls the logic function on a field of the transaction, the setup
part of the main function is not run so the subject is not in the
required state. In fact, the logic function is not even callable by
Anoma because non-main functions in the Juvix module use a calling
convention that assumes the subject has a particular shape.

This PR solves the problem by making all functions in the Juvix module
use the Anoma calling convention. We make all compiled closures
(including, for example, the logic functions stored on resources in a
transaction) self contained, i.e they contain the functions library and
anoma standard library.

Modules that contain many closures produce large nockma output files
which slows down the evaluator. This will need to be fixed in the future
either with Nockma compression ([jam
serialization](https://developers.urbit.org/reference/hoon/stdlib/2p))
or otherwise. But it does not block the compilation and execution of
Anoma transactions.

Other fixes / additions:

* Extra tracing. You can now annotate output cells with a tag that will
be displayed in the output
* Unittests for listToTuple, appendRights helper functions
* Fixes for the nockma parser when parsing 'pretty nockma', specifically
stdlib calls, tags and functions_library atom.
* Adds `juvix dev nock run` command that can run a program output with
the `anoma` target.
* Remove the `nockma` target. As described above we always use the Anoma
calling convention so there's no need for a separate target for the
'juvix calling convention'
* Adds a `--profile` flag to `juvix dev nock run` which outputs a count
of Nockma ops used in the evaluation
* In tests we no longer serialise the compiled program to force full
evaluation of the compiled code. We added a negative test to check that
strings are not allowed in Nockma/Anoma programs,

it is output in a file `OUTPUT.profile` and has the following form:

```
quote : 15077
apply : 0
isCell : 0
suc : 0
= : 4517
if : 5086
seq : 5086
push : 0
call : 4896
replace : 1
hint : 8
scry : 0
trace : 0
```

---------

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2024-03-22 23:03:38 +01:00
.devcontainer upgrade to Ghc 9.8.1 (#2624) 2024-02-07 09:47:48 +00:00
.github Fix linux static binary build workflow (#2634) 2024-02-12 10:25:44 +00:00
app Support compilation of Anoma transactions in nockma backend (#2693) 2024-03-22 23:03:38 +01:00
assets Fix typos (#2573) 2024-01-08 13:27:18 +01:00
bench Release v0.6.0 (#2676) 2024-03-01 09:14:32 +00:00
bench2 Replace polysemy by effectful (#2663) 2024-03-21 12:09:34 +00:00
examples Add field element type (#2659) 2024-02-27 14:54:43 +01:00
gnuplot Automatized benchmarks (#1673) 2023-01-05 17:48:26 +01:00
include Add field element type (#2659) 2024-02-27 14:54:43 +01:00
juvix-stdlib@e2efe4e6fe Update juvix-stdlib submodule reference to main (#2675) 2024-02-29 17:32:55 +00:00
licenses Remove unused files (#2398) 2023-09-28 14:20:19 +02:00
runtime JuvixReg to CASM translation (#2671) 2024-03-20 12:14:12 +01:00
scripts Nockma compile (#2570) 2024-01-17 11:15:38 +01:00
src/Juvix Support compilation of Anoma transactions in nockma backend (#2693) 2024-03-22 23:03:38 +01:00
test Support compilation of Anoma transactions in nockma backend (#2693) 2024-03-22 23:03:38 +01:00
tests Support compilation of Anoma transactions in nockma backend (#2693) 2024-03-22 23:03:38 +01:00
.clang-format Juvix C runtime (#1580) 2022-11-03 09:38:09 +01:00
.github_changelog_generator Update Changelog v0.2.3 🎉 2022-08-15 12:24:42 +02:00
.gitignore Add support for Literate Juvix Markdown (#2448) 2023-11-10 13:55:36 +01:00
.gitmodules Rename MiniJuvix to Juvix (#259) 2022-07-08 13:59:45 +02:00
.hlint.yaml Add default arguments (#2408) 2023-10-10 23:28:06 +02:00
.pre-commit-config.yaml Update clang formatting (#2465) 2023-10-23 19:12:56 +02:00
cabal.hie.yaml Automatized benchmarks (#1673) 2023-01-05 17:48:26 +01:00
cabal.project upgrade to Ghc 9.8.1 (#2624) 2024-02-07 09:47:48 +00:00
cabal.project.freeze upgrade to Ghc 9.8.1 (#2624) 2024-02-07 09:47:48 +00:00
CHANGELOG.md Release v0.6.0 (#2676) 2024-03-01 09:14:32 +00:00
cntlines.sh JuvixReg to CASM translation (#2671) 2024-03-20 12:14:12 +01:00
CONTRIBUTING.md Fix baseUrl for juvix docs in Doctor command (#2122) 2023-05-24 12:14:30 +02:00
justfile Add -XBangPatterns to the justfile (#2627) 2024-02-08 08:31:11 +00:00
LICENSE.md Add new README and md files (#1904) 2023-03-21 20:01:48 +01:00
Makefile Remove BangPattern pragmas (#2626) 2024-02-07 11:46:13 +00:00
package.yaml Replace polysemy by effectful (#2663) 2024-03-21 12:09:34 +00:00
README.md Fix tara url svg (#2406) 2023-09-28 19:05:05 +02:00
stack.hie.yaml Refactor hie.yaml and add entry in the readme (#1672) 2022-12-20 16:45:48 +01:00
stack.yaml Replace polysemy by effectful (#2663) 2024-03-21 12:09:34 +00:00

Juvix

Tara the Juvix mascot

CI Status

The Juvix compiler CI

Nightly build, release and benchmark

Codebase
Open the Juvix Standard Lib in Github Codespace

This repository is specifically dedicated to the compiler of the Juvix programming language.

For any Juvix-related inquiries, we strongly advise visiting the following resources.

Our documentation offers an in-depth understanding of the Juvix programming language. It encompasses a language reference, examples, blog posts, and numerous other resources to facilitate effective use of Juvix.