# How to Run A-MACI Operator Service on vota-sf testnet ## Requirements ### Hardware requirements - CPU: 8 cores - Memory: 16GB - Disk: 100GB ### Software requirements - [nodejs](https://nodejs.org/) version >= 20 - [dorad](https://docs.dorafactory.org/docs/vota-dev/dorad) version: 0.4.0 ## Create an A-MACI operator account > This account will be used later to register as an A-MACI operator. ``` export ACCOUNT_NAME=maci-operator dorad keys add $ACCOUNT_NAME ``` > 🚨🚨🚨Make sure you have backed up the **MNEMONIC** of this account which is the only method to recover your wallet. Also, it will be used when `initiating A-MACI operator service`. ## Register an A-MACI operator on vota-sf 1. Stake 20 DORA to register as A-MACI operator with your `A-MACI operator account`: ```bash! dorad tx wasm execute dora17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsnah3h8 '{"register": {} }' \ --from maci-operator \ --amount "20000000000000000000peaka" \ --chain-id "vota-sf" \ --gas-prices 100000000000peaka \ --gas auto \ --gas-adjustment 1.5 \ --node https://vota-sf-rpc.dorafactory.org:443 \ -y ``` 2. Query whether your A-MACI operator has been created successfully: ```bash! dorad query wasm contract-state smart dora17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsnah3h8 '{ "is_maci_operator": { "address": <your_account_address> } }' --node https://vota-sf-rpc.dorafactory.org:443 ``` If terminal shows `true`, it means the A-MACI operator creation is successful. ```bash! data: true ``` ## Build A-MACI operator service ``` git clone https://github.com/DoraFactory/maci-operator && cd maci-operator npm install npm run build ``` ## Initiate A-MACI operator service ### Configuring environment variables > Please make sure you have navigated to the `/maci-operator` directory. 1. Create your own environment variables file ```bash! cp .env.template .env ``` 2. Generate your Coordinator public and private key ```bash! node dist/gen-key.js ``` > 🚨🚨🚨Please back up the generated public and private keys. > Next, enter the public key into our **[Coordinator public key collection form](https://docs.google.com/spreadsheets/d/1hNlK5qBGrqgZ6UDaLVThjfuvMlX4CsznzWmWCm0QRl0/edit?usp=sharing)**. For example, the format of the public key: ```bash! X: 16429304017412205675820866000313944904446810339972042319485432996531286181952 Y: 5572999208344294573488778747734990567557173306854827005273539480127951622273 ``` 3. Config your MNEMONIC and Coordinator private key - Enter the **mnemonic** of the previously generated `A-MACI operator account` into the `MNEMONIC` field in your `.env` file. - Enter the **Coordinator private key** generated in the previous step into the `COORDINATOR_PRI_KEY` field in your `.env` file. ### Initiate A-MACI operator service ```bash! npm run init ``` ## Setup A-MACI operator service ### Create the definition file Create the definition file in `/etc/systemd/system/amaci.service`. ```bash! [Unit] Description=A-MACI-operator-service After=network-online.target [Service] User=<USER> WorkingDirectory=<PATH_TO_maci-operator> EnvironmentFile=<PATH_TO_maci-operator>/.env ExecStart=/usr/bin/node dist/index.js RestartSec=10 Restart=on-failure LimitNOFILE=655350 [Install] WantedBy=multi-user.target ``` - `<USER>`: Enter the user (likely your username or root, unless you created a user specifically for A-MACI operator service). - `<PATH_TO_maci-operator>`: Enter the path to the `maci-operator` directory, which is likely `/home/ubuntu/maci-operator`. ### Run the program upon startup After registering `amaci` as a system service, you can set the program to run upon startup. ```bash! systemctl daemon-reload systemctl enable amaci ``` ### Start the service and check the log ```bash! sudo systemctl start amaci sudo journalctl -u amaci -f --no-hostname -o cat ``` If it started successfully, you will see many similar logs like this: ```shell= [DO]: inspect [TASK inspect] find rounds count: 0/0 [DO]: inspect [TASK inspect] find rounds count: 0/0 [DO]: inspect ``` ### What is the A-MACI Operator service doing? - The A-MACI Operator service periodically checks A-MACI Rounds that need to be processed on the `vota-sf` testnet. - The A-MACI Operator service logs processed A-MACI Round information and other data in the `/maci-operator/work` directory.