Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include the anoma library nock code in the compiled nockma output #3117

Open
paulcadman opened this issue Oct 22, 2024 · 0 comments
Open
Assignees
Labels
Milestone

Comments

@paulcadman
Copy link
Collaborator

paulcadman commented Oct 22, 2024

⚠️ We should defer this until we can run CI tests against the Anoma Node nock interpreter. See discussion below.

Following on from:

When executing a function, the Anoma client / Anoma node replaces the last element of the Nock list in the environment slot of the function with the Anoma library. This corresponds to the AnomaLibrary constructor in AnomaCallablePathId:

-- The AnomaLibrary constructor must be last. Anoma will replace the tail of
-- the main function with the Anoma Resource Machine standard library when it
-- calls it.
data AnomaCallablePathId
= FunCode
| ArgsTuple
| ---
ClosureRemainingArgsNum
| FunctionsLibrary
| AnomaLibrary
deriving stock (Enum, Bounded, Eq, Show)

During the main function call we populate the AnomaLibrary slot with the Nock code of the Anoma library: https://github.com/anoma/juvix/blob/d741fbc9717faa2dc172d1c47a67921f1c8f22a3/runtime/nockma/anomalib.nockma

The Anoma client / Anoma node will populate this slot for us, so we don't need to include the Anoma library nock code in the compiled output.

The reason why we've deferred this is because the locations of functions in the Anoma library nock code must necessarily be hard coded in the compiler. And so the anoma lib we build and test with must exactly match what is provided by the Anoma node. We do not have tests that run against the Anoma node interpreter so it's safer for now to bundle the Anoma library code in the compiled output. The tradeoff is that the compiled output will be larger, but the size of the Anoma library is small compared to the total compiled output of normal programs.

For this issue:

  1. Populate the AnomaLibrary slot with the nock list nil terminator (i.e 0) instead of populating it with the Anoma library nock code. To do this we adapt the code that populates this slot when constructing the main function:

  1. Update the Anoma / nockma test runner to inject the Anoma library code into the AnomaLibrary slot of functions being tested.

  2. Make sure there are tests that run the compiled output with the Anoma node nock interpreter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants