Understanding any code in Anoma

Index

  1. Toc
  2. Contributing
    1. Understanding Any Module
    2. Style Guide
    3. Writing Documents
    4. Examples Over Testing
    5. Git
    6. Iex
    7. Mnesia Vs Actor State
    8. Observer
    9. Testing
      1. Running Tests
      2. Writing Tests
  3. Visualization
    1. Actors
  4. Hoon
    1. Calling
    2. Dumping
    3. Setting Up
  5. Analysis

Figuring out what a module does

Α good start is by calling h on the module from within one's IEX instance.

require IEx.Helpers
import IEx.Helpers
# the above two lines are not requried for the REPL!
h(Anoma.Node.Transaction.Backends)

                        Anoma.Node.Transaction.Backends

Backend module. Support :kv, :ro, :rm, :cairo execution.

However, this typically doesn't show off how one uses said module. Thankfully, the codebase is setup in such a way that one can always interactively play with any given module.

This is done by simply checking out the examples folder, and finding the module you wish to learn to learn about.

For example, let us learn about the nock. In the codebase currently this can be found here:

  • anoma/apps/anoma_lib/lib/examples/enock.ex,

note that even if this gets out of date, you should be able to do this with any file!

From here every example shows off how the API works, code can be ran line by line, by simply running all the aliases and importing the module itself.

# output redacted for length
import Examples.ENock

require ExUnit.Assertions
import ExUnit.Assertions

alias Examples.ECrypto
Examples.ECrypto

Once this is had, we can simply run any example trivially!

one_two()
[<<1>> | <<2>>]

Further since the data is live, we can use tools like :observer to view the processes, and see general state dumping commands.