/powerpool-agent-v2-compose

🖥️ The repository contains Docker Compose file to easily start the Power Agent V2 Node and related services.

Primary LanguageJavaScript

PowerPool Agent V2 Keeper Node Docker image

The node monitors on-chain events and executes jobs when required.

Official PPAgentV2 deployments

To see active Power Agent V2 deployments, go to app.powerpool.finance.

Creating a Keeper and setting up a node using docker image

Signing up as a Keeper

To be a keeper, you need at least two keys. (1) One admin key for management and (2) another one for a worker. The management key function is to assign a worker's address and withdraw compensations or initial deposit. The worker key is needed for transaction signing by a node.

To sign as a Keeper you need to perform the following actions:

1. Open Power Agent dApp

Go to app.powerpool.finance. Here, you can see all available Power Agent contracts for the selected network and click the Create Keeper button. Screenshot 2023-10-10 at 13 38 21

2. Create your Keeper

In the pop-up modal window, the Admin address will be set automatically to the connected wallet. Manually fill in the Worker address and the CVP stake amount, ensuring it's above the minimum level. Your CVP stake determines the compensation the Keeper receives and their ability to be assigned a job. Sign the approval transaction and then create a Keeper. Screenshot 2023-10-10 at 13 39 45

3. Check My Keepers

You will see all your created keepers in the My Keepers section. ⚠️ Attention! You have created a Keeper that is not active. Please do not activate it now. Screenshot 2023-10-10 at 13 18 27

Setting up a Power Agent node using docker image

git clone https://github.com/powerpool-finance/powerpool-agent-v2-compose
cd powerpool-agent-v2-compose
  • Place a JSON file containing your worker key into the ./keys folder. You can choose any filename. If you don't yet have a JSON key file, you can use the JSON key generator from this repository. To convert your raw private key to the JSON V3 format, use the following syntax:

    # node jsongen.js <your-private-key> <your-pass>
    yarn
    node jsongen.js 0x0c38f1fb1b2d49ea6c6d255a6e50edf0a7a7fa217639281fe1b24a96efc16995 myPass
  • Copy the main config template:

cp config/main.template.yaml main.yaml
  • Edit main.yaml using nano, vim or any other editor.

  • You can edit main.yaml file and add as many networks and agents as you need. However, at the current stage, it's highly recommended to use only one Network and Power Agent contract.

  • Enter your WebSockets RPC node URI in networks->details->{network_name}->rpc. The example config might include some RPC nodes, either public ones or those maintained by PowerPool. However, we cannot guarantee that they will operate flawlessly with excellent uptime. To achieve better uptime, it is highly recommended to use your own personal RPC.

  • For each Agent contract address (networks->details->{network_name}->agents->{agent_address}):

    • Choose pga executor.
    • Put your Keeper worker address into keeper_address.
    • Put your Keeper worker json key password into key_pass.
    • If you wish to accrue rewards on your balance in the Power Agent contract (which could save a small amount of gas), set accrue_reward to true. If set to false, the compensation will be sent to the worker's address after each job execution. The default value is false.
  • Please note that you cannot add more than one Keeper for a given agent contract on a single node. If you wish to set up more than one Keeper, we recommend setting up another node, preferably on a different host. Using different RPCs or even different regions are also good options.

  • The main.yaml file should look like this example for Sepolia:

networks:
  enabled:
    - sepolia
  details:
    sepolia:
      rpc: 'wss://sepolia-1.powerpool.finance'
      agents:
        '0xbdE2Aed54521000DC033B67FB522034e0F93A7e5':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/query/48711/ppav2-rd-sepolia-b12-ui/version/latest
          executor: pga
          keeper_worker_address: '0x840ccC99c425eDCAfebb0e7ccAC022CD15Fd49Ca'
          key_pass: 'Very%ReliablePassword292'
          accrue_reward: false
  • The main.yaml file should look like this example for Gnosis chain:
networks:
  enabled:
    - gnosis
  details:
    gnosis:
      rpc: 'wss://gnosis-1.powerpool.finance'
      agents:
        '0x071412e301C2087A4DAA055CF4aFa2683cE1e499':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/query/48711/ppav2-rd-gnosis-b12-ui/version/latest
          executor: pga
          keeper_worker_address: '0x840ccC99c425eDCAfebb0e7ccAC022CD15Fd49Ca'
          key_pass: 'Very%ReliablePassword292'
          accrue_reward: false
  • The main.yaml file should look like this example for Ethereum mainnet:
networks:
  enabled:
    - mainnet
  details:
    mainnet:
      rpc: 'wss://mainnet-1.powerpool.finance'
      agents:
        '0xc9ce4CdA5897707546F3904C0FfCC6e429bC4546':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/query/48711/ppav2-rd-gnosis-b12-ui/version/latest
          executor: pga
          keeper_worker_address: '0x840ccC99c425eDCAfebb0e7ccAC022CD15Fd49Ca'
          key_pass: 'Very%ReliablePassword292'
          accrue_reward: false
  • Go back and run a docker container:
cd ..
docker compose --profile latest up -d
Screenshot 2023-10-10 at 15 29 11
  • Get container ID:
ubuntu@home:~/powerpool-agent-v2-compose$ docker compose ps

NAME                                            IMAGE                                           COMMAND                  SERVICE            CREATED        STATUS        PORTS
powerpool-agent-v2-compose-agent-latest-1       powerpool/power-agent-node:latest               "./docker-entrypoint…"   agent-latest       21 hours ago   Up 21 hours   0.0.0.0:8199->8199/tcp, :::8199->8199/tcp
powerpool-agent-v2-compose-offchain-service-1   powerpool/power-agent-offchain-service:latest   "docker-entrypoint.s…"   offchain-service   21 hours ago   Up 21 hours   3423/tcp, 0.0.0.0:3424->3424/tcp, :::3424->3424/tcp
  • Check logs (using SERVICE name):
docker compose logs agent-latest -f
  • Check logs (using profile):
docker compose --profile latest logs -f

Eventually, you will see the following logs in the console. Pay attention: your keeper is still disabled, so you cannot execute jobs. Screenshot 2023-10-10 at 15 28 47

Activate Keeper

Go back to https://app.powerpool.finance/#/sepolia/ppv2/my-keepers, click the 'Complete' button, and then sign the transaction. Screenshot 2023-10-10 at 13 29 22 In the console, you will see that the Keeper was successfully activated. Congratulations! Screenshot 2023-10-10 at 15 41 57

App exit codes

  1. Not an actual error, but some condition when it's better to restart an entire app. Used for some event handlers.
  2. Critical errors. Should stop the app. For ex. worker address not found, can't resolve RPC, etc.
  3. Non-critical errors. Should restart the app. For ex. hanged WS endpoint connection.

Privacy

The Power Agent node sends basic, anonymous data about transactions to the backend for debugging.

Updating your Power Agent node

docker compose --profile latest down
git pull && docker compose pull
docker compose --profile latest up -d

Migrating your keeper to a new Power Agent contract

  • Register as a keeper at the new contract.
  • Update the contract address in the corresponding config section.
  • If you want to use a different address for the keeper worker, update the corresponding fields in the config.
  • Update your Power Agent node (see the instructions above).

Watching Power Agent Node Logs

⚠️ Attention! Don't forget to change container id.

  • docker logs -fn100 e8651565f365 to follow the contanter logs starting from 100 lines behind.
  • docker logs e8651565f365 > out.txt to save all the container logs to out.txt file.

Run Keeper in Dev Mode with Additional Logging Levels

Run Keeper in development mode with enhanced logging or specific api ports:

NODE_ENV=dev NODE_API_PORT=8199 OFFCHAIN_API_PORT=3424 docker compose --profile latest up -d

This sets the environment to development, increasing log detail, and runs the container in the background.

Run the Power Agent Node Container with the 'dev' Tag

Run the Power Agent Node with the 'dev' tag for development and testing. This version includes the latest updates not in the stable release.

docker compose pull
NODE_ENV=dev docker compose --profile dev up -d