Aquarius is an off-chain component that caches the asset's metadata published on-chain. By deploying their own instance of Aquarius, developers can control which assets are visible in their DApp. For example, having a custom Aquarius instance allows only the assets from specific addresses to be visible in the DApp.
This tutorial will provide the steps to deploy Aquarius. Ocean Protocol provides Aquarius Docker images which can be viewed here. Visit this page to view the Aquarius source code.
Aquarius consists of two parts:
API: The Aquarius API provides a user with a convenient way to access the metadata without scanning the chain itself.
Event monitor: Aquarius continually monitors the chains for MetadataCreated and MetadataUpdated events, processes these events, and adds them to the database.
As mentioned in the Setup a Server document, all Ocean components can be deployed in two configurations: simple, based on Docker Engine and Docker Compose, and complex, based on Kubernetes with Docker Engine. This document will present how to deploy Aquarius in each of these configurations.
Deploying Aquarius using Docker Engine and Docker Compose
This guide will deploy Aquarius, including Elasticsearch as a single systemd service.
Prerequisites
A server for hosting Aquarius. See this guide for how to create a server;
Docker Compose and Docker Engine are installed and configured on the server. See this guide for how to install these products.
The RPC URLs and API keys for each of the networks to which the Aquarius will be connected. See this guide for how to obtain the URL and the API key.
Steps
1. Create the /etc/docker/compose/aquarius/docker-compose.yml file
From a terminal console, create /etc/docker/compose/aquarius/docker-compose.yml file, then copy and paste the following content to it. Check the comments in the file and replace the fields with the specific values of your implementation. The following example is for deploying Aquarius for Goerli network.
For each other network in which you want to deploy Aquarius, add to the file a section similar to "aquarius-events-goerli" included in this example and update the corresponding parameters (i.e. EVENTS_RPC, OCEAN_ADDRESS, SUBGRAPH_URLS) specific to that network.
Create the /etc/systemd/system/[email protected] file then copy and paste the following content to it. This example file could be customized if needed.
[Unit]Description=%i service with docker composeRequires=docker.serviceAfter=docker.service[Service]Type=oneshotRemainAfterExit=trueEnvironment="PROJECT=ocean"WorkingDirectory=/etc/docker/compose/%iExecStartPre=/usr/bin/env docker-compose -p $PROJECT pullExecStart=/usr/bin/env docker-compose -p $PROJECT up -dExecStop=/usr/bin/env docker-compose -p $PROJECT stopExecStopPost=/usr/bin/env docker-compose -p $PROJECT down[Install]WantedBy=multi-user.target
3. Reload the systemd manager configuration
Run the following command to reload the systemd manager configuration
sudosystemctldaemon-reload
Optionally, you can enable the services to start at boot, using the following command:
Run the following commands to access Aquarius The output should be similar to the one displayed here.
$curllocalhost:9200{"name":"a93d989293ac","cluster_name":"docker-cluster","cluster_uuid":"Bs16cyCwRCOIbmaBUEj5fA","version":{"number":"8.7.0","build_flavor":"default","build_type":"docker","build_hash":"09520b59b6bc1057340b55750186466ea715e30e","build_date":"2023-03-27T16:31:09.816451435Z","build_snapshot":false,"lucene_version":"9.5.0","minimum_wire_compatibility_version":"7.17.0","minimum_index_compatibility_version":"7.0.0" },"tagline":"You Know, for Search"}
Aquarius supports indexing multiple chains using a single instance to serve API requests and one instance for each chain that must be indexed.
The following deployment templates could be used for guidance. Some parameters are optional and the template could be adjusted based on these considerations. Common cases are the deployments for one/multiple Ethereum networks:
Mainnet
Sepolia
a. Create a YAML file for Aquarius configuration.
The following templates (annotated) could be edited and used for deployment.
apiVersion:apps/v1kind:Deploymentmetadata:annotations:labels:app:aquariusname:aquariusspec:progressDeadlineSeconds:600replicas:1revisionHistoryLimit:5selector:matchLabels:app:aquariusstrategy:rollingUpdate:maxSurge:25%maxUnavailable:25%type:RollingUpdatetemplate:metadata:creationTimestamp:nulllabels:app:aquariusspec:containers: - env: - name:LOG_LEVELvalue:DEBUG - name:AQUARIUS_URLvalue:http://0.0.0.0:5000 - name:AQUARIUS_WORKERSvalue:"4" - name:DB_HOSTNAMEvalue:< ES service hostname > - name:DB_MODULEvalue:elasticsearch - name:DB_NAMEvalue:aquarius - name:DB_PORTvalue:"9200" - name:DB_SCHEMEvalue:http - name:DB_USERNAMEvalue:< ES username > - name:DB_PASSWORDvalue:< ES password > - name:DB_SSLvalue:"false" - name:RUN_AQUARIUS_SERVERvalue:"1" - name:RUN_EVENTS_MONITORvalue:"0" - name:EVENTS_ALLOWvalue:"0" - name:CONFIG_FILEvalue:config.ini - name:ALLOWED_PUBLISHERSvalue:'[""]'image:oceanprotocol/aquarius:v5.1.2 => check the available versions:https://hub.docker.com/repository/docker/oceanprotocol/aquarius/tags?page=1&ordering=last_updatedimagePullPolicy:AlwayslivenessProbe:failureThreshold:3httpGet:path:/port:5000scheme:HTTPinitialDelaySeconds:20periodSeconds:10successThreshold:1timeoutSeconds:2name:aquariusports: - containerPort:5000protocol:TCPreadinessProbe:failureThreshold:3httpGet:path:/port:5000scheme:HTTPinitialDelaySeconds:20periodSeconds:10successThreshold:1timeoutSeconds:1resources:limits:cpu:800mmemory:1Girequests:cpu:800mmemory:1GiterminationMessagePath:/dev/termination-logterminationMessagePolicy:FilednsPolicy:ClusterFirstrestartPolicy:AlwaysschedulerName:default-schedulerterminationGracePeriodSeconds:30ya
Example deployment for Sepoia (Polygon testnet):
aquarius-events-sepolia-deployment.yaml (annotated) - this deployment will be responsible for indexing the block and storing the metadata published on-chain:
apiVersion:apps/v1kind:Deploymentmetadata:annotations:labels:app:aquarius-events-sepolianame:aquarius-events-sepoliaspec:progressDeadlineSeconds:600replicas:1revisionHistoryLimit:5selector:matchLabels:app:aquarius-events-sepoliastrategy:rollingUpdate:maxSurge:25%maxUnavailable:25%type:RollingUpdatetemplate:metadata:creationTimestamp:nulllabels:app:aquarius-events-sepoliaspec:containers: - env: - name:LOG_LEVELvalue:DEBUG - name:AQUARIUS_URLvalue:http://0.0.0.0:5000 - name:AQUARIUS_WORKERSvalue:"1" - name:DB_HOSTNAMEvalue:< ES service hostname > - name:DB_MODULEvalue:elasticsearch - name:DB_NAMEvalue:aquarius - name:DB_PORTvalue:"9200" - name:DB_SCHEMEvalue:http - name:DB_USERNAMEvalue:< ES username > - name:DB_PASSWORDvalue:< ES password > - name:DB_SSLvalue:"false" - name:RUN_AQUARIUS_SERVERvalue:"0" - name:RUN_EVENTS_MONITORvalue:"1" - name:CONFIG_FILEvalue:config.ini - name:ALLOWED_PUBLISHERSvalue:'[""]' - name:NETWORK_NAMEvalue:sepolia - name:EVENTS_RPCvalue:https://polygon-sepolia.infura.io/v3/< INFURA ID > => or another RPC service for this network - name:METADATA_UPDATE_ALLvalue:"0" - name:ASSET_PURGATORY_URLvalue:https://raw.githubusercontent.com/oceanprotocol/list-purgatory/main/list-assets.json - name:ACCOUNT_PURGATORY_URLvalue:https://raw.githubusercontent.com/oceanprotocol/list-purgatory/main/list-accounts.json - name:PURGATORY_UPDATE_INTERVALvalue:"60" - name:OCEAN_ADDRESSvalue:0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8 - name:SUBGRAPH_URLSvalue:| {"80001": "https://v4.subgraph.sepolia.oceanprotocol.com"} => or your own deployed Ocean Subgraph service for this network - name:BLOCKS_CHUNK_SIZEvalue:"3500" - name:EVENTS_HTTPvalue:"1"image:oceanprotocol/aquarius:v5.1.2 => check the available versions:https://hub.docker.com/repository/docker/oceanprotocol/aquarius/tags?page=1&ordering=last_updatedimagePullPolicy:AlwayslivenessProbe:failureThreshold:3httpGet:path:/port:5001scheme:HTTPinitialDelaySeconds:20periodSeconds:10successThreshold:1timeoutSeconds:1name:aquarius-events-sepoliaports: - containerPort:5000protocol:TCPreadinessProbe:failureThreshold:3httpGet:path:/port:5001scheme:HTTPinitialDelaySeconds:20periodSeconds:10successThreshold:1timeoutSeconds:1resources:limits:cpu:500mmemory:1Girequests:cpu:500mmemory:1GiterminationMessagePath:/dev/termination-logterminationMessagePolicy:FilednsPolicy:ClusterFirstrestartPolicy:AlwaysschedulerName:default-schedulerterminationGracePeriodSeconds:30
Tip: before deployment, you can validate the yaml file.
b. Deploy the configuration
Deploy the configuration in Kubernetes using the following commands.
The next step is to create a Kubernetes service (eg. ClusterIP, NodePort, Loadbalancer, ExternalName) for this deployment, depending on the environment specifications. Follow this link for details on how to create a Kubernetes service.