Skip to content

The ar.io network smart contract implementation for AO.

License

Notifications You must be signed in to change notification settings

ar-io/ar-io-network-process

Repository files navigation

AO/IO Network Process

codecov $ARIO Network Status

The implementation of the ar.io network contract is written in lua and deployed as an AO process on Arweave. The contract is responsible for managing the network state, handling transactions, and enforcing the network rules. Refer to the contract whitepaper for more details on the network rules and the contract design.

Networks

Specs

Refer to the AR.IO Network Spec document for more details on the contract actions and their inputs and outputs.

Deployments

Testnet & Devnet

Merging to develop or main will evolve the devnet or testnet contract to the latest source code. The script managing the logic is located at tools/evolve.mjs, which uses aoconnect to perform an Eval action. The deployment process is automated using Github Actions.

To manually apply updates to the devnet or testnet contract, run the following command:

aos <network-process-id> --cu-url https://cu.ardrive.io --wallet /path/to/wallet.json

From there, you can perform an Eval action to apply the updates:

Devnet [email protected][Inbox:270]>  .load process.lua (or some other lua code)

Mainnet

Mainnet deployment is managed manually by the AR.IO team via modules in ar-io/aos forked repository. The process is owned by a an ar-io/vaot multi-sig process (available at vaot.ar.io) and requires majority of controllers to approve evals before the update is applied.

Monitoring

Monitor tests leverage the [ar-io-sdk] to evaluate the state of the network and intended to detect invariant states on the network process. These tests spin up a local AO CU service via testcontainers and evaluate the state of the network process.

To run the monitor tests, execute the following command:

yarn monitor:<devnet|testnet|mainnet>

You can also choose to run the monitor tests against a specific forked process by setting the ARIO_PROCESS_ID environment variable:

ARIO_PROCESS_ID=<process-id> yarn monitor

You can also use the ad-hoc workflow to evaluate a forked process by setting the ARIO_PROCESS_ID environment variable and running the workflow via GitHub Actions.

Tests

Unit Tests

Unit tests are written using the Busted framework. To run the tests, execute the following command:

busted . or yarn test:unit

To run the tests with debugging (includes print statements), set the DEBUG environment variable to true:

DEBUG=true busted . or yarn test:unit:debug

Integration Tests

Integration tests are written using the ao-loader. To run the tests, execute the following command:

yarn test:integration

Developers

Requirements

Lua Setup (MacOS)

  1. Clone the repository and navigate to the project directory.
  2. Install lua
  1. Add the following to your zshrcor bashrcfile:
echo 'export LDFLAGS="-L/usr/local/opt/[email protected]/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/usr/local/opt/[email protected]/include/lua5.3"' >> ~/.zshrc
echo 'export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  1. Run source ~/.zshrcor source ~/.bashrcto apply the changes.
  2. Run lua -vto verify the installation.

LuaRocks Setup

  1. Install luarocks
curl -R -O http://luarocks.github.io/luarocks/releases/luarocks-3.9.1.tar.gz
tar zxpf luarocks-3.9.1.tar.gz
cd luarocks-3.9.1
./configure --with-lua=/usr/local/opt/[email protected] --with-lua-include=/usr/local/opt/[email protected]/include/lua5.3
make build
sudo make install
  1. Ensure that the luarocksbinary is in your path by running echo $PATH Otherwise, add it to your path and reload your shell:
echo 'export PATH=$HOME/.luarocks/bin:$PATH' >> ~/.zshrc
  1. Check the installation by running luarocks --version
  2. Check the LuaRocks configuration by running luarocks config | grep LUA

If you ever need to refresh .luarocks, run the following command:

luarocks purge && luarocks install ar-io-ao-0.1-1.rockspec

aos

Get aos:

yarn global add https://get_ao.g8way.io

To load the module into the aos REPL, run the following command:

aos --load process.lua

Code Formatting

To get the code formatter, we'll need to install rust to access cargo To install rust on MacOS, run the following command:

brew install rust

If not already added, include cargobinary in your path so that packages installed using cargocan be accessed globally:

echo 'export PATH=$HOME/.cargo/bin:$PATH' >> ~/.zshrc

The code is formatted using stylua To install stylua, run the following command:

cargo install stylua
stylua contract

Dependencies

To add new dependencies, install using luarocks to the local directory

luarocks install <package>

And add the package to the dependenciestable in the ar-io-ao-0.1-1.rockspecfile.

-- rest of the file
dependencies = {
    "lua >= 5.3",
    "luaunit >= 3.3.0",
    "<package>"
}

About

The ar.io network smart contract implementation for AO.

Resources

License

Stars

Watchers

Forks

Packages

No packages published