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.
- Mainnet - qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE
- Testnet - agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA
- Devnet - GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc
Refer to the AR.IO Network Spec document for more details on the contract actions and their inputs and outputs.
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 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.
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.
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 are written using the ao-loader. To run the tests, execute the following command:
yarn test:integration
- Clone the repository and navigate to the project directory.
- Install
lua
brew install [email protected]
- Add the following to your
zshrc
orbashrc
file:
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
- Run
source ~/.zshrc
orsource ~/.bashrc
to apply the changes. - Run
lua -v
to verify the installation.
- 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
- Ensure that the
luarocks
binary is in your path by runningecho $PATH
Otherwise, add it to your path and reload your shell:
echo 'export PATH=$HOME/.luarocks/bin:$PATH' >> ~/.zshrc
- Check the installation by running
luarocks --version
- 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
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
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 cargo
binary in your path so that packages installed using cargo
can 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
To add new dependencies, install using luarocks to the local directory
luarocks install <package>
And add the package to the dependencies
table in the ar-io-ao-0.1-1.rockspec
file.
-- rest of the file
dependencies = {
"lua >= 5.3",
"luaunit >= 3.3.0",
"<package>"
}