Skip to content

🖥️ Node for Power Agent V2: The Node is an off-chain software that reads data about the current network state from Subquery or Subgraph indexers, handles events from different implementations of Power Agent V2 contracts on various blockchains and rollups, automatically sends transactions, and performs slashing in case of no execution.

Notifications You must be signed in to change notification settings

powerpool-finance/powerpool-agent-v2-node

Repository files navigation

PowerPool Agent V2 Keeper Node

GitHub Workflow Status

The node monitors on-chain events and executes jobs when required. This node is distributed as a Docker image and a DappNode package. However, you can also build it from the source by following the instructions below.

Detailed instructions on how to setup a Keeper Node:

Official PPAgentV2 deployments

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

Creating a Keeper and setting up a node from the source code

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 from the source code

  • Install Node.js version 18.

  • Clone this repository:

    git clone https://github.com/powerpool-finance/powerpool-agent-v2-node.git
    cd powerpool-agent-v2-node
  • Install dependencies and build Power Agent node:

    yarn && yarn build
  • 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>
    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:
        '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
  • To start the node and ensure that everything is okay:
node dist/Cli.js
  • To start the node in background using pm2:
yarn add global pm2
pm2 start dist/Cli.js --name power-agent
pm2 startup && pm2 save
  • There is an alternative way to start the node by using only environment variables instead of a config file:
NETWORK_NAME='sepolia' NETWORK_RPC='wss://sepolia-1.powerpool.finance' AGENT_ADDRESS='0xbdE2Aed54521000DC033B67FB522034e0F93A7e5' KEEPER_WORKER_ADDRESS='0x840ccC99c425eDCAfebb0e7ccAC022CD15Fd49Ca' KEYPASSWORD='Very%ReliablePassword292' node dist/Cli.js
  • Full list of environment variables:
    • NETWORK_NAME - Name of the network (e.g., sepolia, goerli, gnosis, ethereum, etc.)

    • NETWORK_RPC - Provided RPC URL

    • AGENT_ADDRESS - Power Agent smart contract address

    • KEEPER_WORKER_ADDRESS - Your Worker address

    • KEYPASSWORD - Password for your keyfile

    • DATA_SOURCE - Currently only 'subgraph'.

    • SUBGRAPH_URL - URL for the subgraph (e.g., https://api.studio.thegraph.com/query/48711/ppav2-rd-sepolia-b12-ui/version/latest).

    • ACCRUE_REWARD - If provided, will be set to true

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 13 28 12

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 13 29 51

Build Docker image from sources

docker buildx build -t power-agent-node:latest .

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.

About

🖥️ Node for Power Agent V2: The Node is an off-chain software that reads data about the current network state from Subquery or Subgraph indexers, handles events from different implementations of Power Agent V2 contracts on various blockchains and rollups, automatically sends transactions, and performs slashing in case of no execution.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages