|
| 1 | +--- |
| 2 | +title: TAP Migration Guide |
| 3 | +--- |
| 4 | + |
| 5 | +Learn about The Graph’s new payment system, **Timeline Aggregation Protocol, TAP**. This system provides fast, efficient microtransactions with minimized trust. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +[TAP](https://docs.rs/tap_core/latest/tap_core/index.html) is a drop-in replacement to the Scalar payment system currently in place. It provides the following key features: |
| 10 | + |
| 11 | +- Efficiently handles micropayments. |
| 12 | +- Adds a layer of consolidations to on-chain transactions and costs. |
| 13 | +- Allows Indexers control of receipts and payments, guaranteeing payment for queries. |
| 14 | +- It enables decentralized, trustless gateways and improves `indexer-service` performance for multiple senders. |
| 15 | + |
| 16 | +## Specifics |
| 17 | + |
| 18 | +TAP allows a sender to make multiple payments to a receiver, **TAP Receipts**, which aggregates these payments into a single payment, a **Receipt Aggregate Voucher**, also known as a **RAV**. This aggregated payment can then be verified on the blockchain, reducing the number of transactions and simplifying the payment process. |
| 19 | + |
| 20 | +For each query, the gateway will send you a `signed receipt` that is stored on your database. Then, these queries will be aggregated by a `tap-agent` through a request. Afterwards, you’ll receive a RAV. You can update a RAV by sending it with newer receipts and this will generate a new RAV with an increased value. |
| 21 | + |
| 22 | +### RAV Details |
| 23 | + |
| 24 | +- It’s money that is waiting to be sent to the blockchain. |
| 25 | + |
| 26 | +- It will continue to send requests to aggregate and ensure that the total value of non-aggregated receipts does not exceed the `amount willing to lose`. |
| 27 | + |
| 28 | +- Each RAV can be redeemed once in the contracts, which is why they are sent after the allocation is closed. |
| 29 | + |
| 30 | +### Redeeming RAV |
| 31 | + |
| 32 | +As long as you run `tap-agent` and `indexer-agent`, everything will be executed automatically. The following provides a detailed breakdown of the process: |
| 33 | + |
| 34 | +1. An Indexer closes allocation. |
| 35 | + |
| 36 | +2. `<recently-closed-allocation-buffer> period, tap-agent` takes all pending receipts for that specific allocation and requests an aggregation into a RAV, marking it as `last`. |
| 37 | + |
| 38 | +3. `indexer-agent` takes all the last RAVS and sends redeem requests to the blockchain, which will update the value of `redeem_at`. |
| 39 | + |
| 40 | +4. During the `<finality-time>` period, `indexer-agent` monitors if the blockchain has any reorganizations that revert the transaction. |
| 41 | + |
| 42 | + - If it was reverted, the RAV is resent to the blockchain. If it was not reverted, it gets marked as `final`. |
| 43 | + |
| 44 | +## Blockchain Addresses |
| 45 | + |
| 46 | +### Contracts |
| 47 | + |
| 48 | +| Contract | Arbitrum Sepolia | Arbitrum Mainnet | |
| 49 | +| ------------------- | ------------------------------------------ | ------------------------------------------ | |
| 50 | +| Contract | Arbitrum Sepolia (421614) | Arbitrum Mainnet (42161) | |
| 51 | +| TAP Verifier | 0xfC24cE7a4428A6B89B52645243662A02BA734ECF | 0x33f9E93266ce0E108fc85DdE2f71dab555A0F05a | |
| 52 | +| AllocationIDTracker | 0xAaC28a10d707bbc6e02029f1bfDAEB5084b2aD11 | 0x5B2F33d7Ca6Ec88f5586f2528f58c20843D9FE7c | |
| 53 | +| Escrow | 0x1e4dC4f9F95E102635D8F7ED71c5CdbFa20e2d02 | 0x8f477709eF277d4A880801D01A140a9CF88bA0d3 | |
| 54 | + |
| 55 | +### Gateway |
| 56 | + |
| 57 | +| Component | Edge and Node (Testnet) | Edge and Node Mainnet (42161) | |
| 58 | +| --- | --- | --- | |
| 59 | +| Sender | 0xC3dDf37906724732FfD748057FEBe23379b0710D | 0xDDE4cfFd3D9052A9cb618fC05a1Cd02be1f2F467 | |
| 60 | +| Signers | 00xFb142dE83E261e43a81e9ACEADd1c66A0DB121FE | 0xfF4B7A5EfD00Ff2EC3518D4F250A27e4c29A2211 | |
| 61 | +| Aggregator | [for testnet](https://tap-aggregator.testnet.thegraph.com) | [for Mainnet](https://tap-aggregator.network.thegraph.com) | |
| 62 | + |
| 63 | +### Requirements |
| 64 | + |
| 65 | +In addition to the typical requirements to run an indexer, you’ll need a `tap-escrow-subgraph` endpoint to query TAP updates. You can use The Graph Network to query or host yourself on your `graph-node`. |
| 66 | + |
| 67 | +> Note: `indexer-cli` does not currently have a command to index this subgraph like it does for `graph-network`. As a result, you have to index it manually. |
| 68 | +
|
| 69 | +## Migration Guide |
| 70 | + |
| 71 | +### Prerequisites |
| 72 | + |
| 73 | +Make sure you have the following version: `<insert the version here>` |
| 74 | + |
| 75 | +### Steps |
| 76 | + |
| 77 | +1. **Indexer Agent** |
| 78 | + |
| 79 | + - Follow the [same process](https://github.com/graphprotocol/indexer/pkgs/container/indexer-agent#graph-protocol-indexer-components). |
| 80 | + - Use the new argument `–tap-subgraph-endpoint`. |
| 81 | + |
| 82 | +2. **Indexer Service** |
| 83 | + |
| 84 | + - Fully replace your current configuration with the new application. |
| 85 | + - You can reuse some of the values in your environment variables and command arguments inside the configuration. |
| 86 | + > It’s critical to install the new `tap-agent` component to receive your payments. |
| 87 | +
|
| 88 | +3. **Configure** |
| 89 | + |
| 90 | + Configuration is shared between components, enabling you to use a single configuration for both `indexer-service` and `tap-agent`. Each component will use the required fields. |
| 91 | + |
| 92 | + Check out the full [configuration](https://github.com/graphprotocol/indexer-rs/blob/main/config/maximal-config-example.toml) and the [default values](https://github.com/graphprotocol/indexer-rs/blob/main/config/default_values.toml) |
| 93 | + |
| 94 | +For minimal configuration, use the following: |
| 95 | + |
| 96 | +```bash |
| 97 | +# You will have to change *all* the values below to match your setup. |
| 98 | +# |
| 99 | +# Some of the config below are global graph network values, which you can find here: |
| 100 | +# <https://github.com/graphprotocol/indexer/tree/main/docs/networks> |
| 101 | +# |
| 102 | +# Pro tip: if you need to load some values from the environment into this config, you |
| 103 | +# can overwrite with environment variables. For example, the following can be replaced |
| 104 | +# by [PREFIX]_DATABASE_POSTGRESURL, where PREFIX can be `INDEXER_SERVICE` or `TAP_AGENT`: |
| 105 | +# |
| 106 | +# [database] |
| 107 | +# postgres_url = "postgresql://indexer:${POSTGRES_PASSWORD}@postgres:5432/indexer_components_0" |
| 108 | + |
| 109 | +[indexer] |
| 110 | +indexer_address = "0x1111111111111111111111111111111111111111" |
| 111 | +operator_mnemonic = "celery smart tip orange scare van steel radio dragon joy alarm crane" |
| 112 | + |
| 113 | +[database] |
| 114 | +# The URL of the Postgres database used for the indexer components. The same database |
| 115 | +# that is used by the `indexer-agent`. It is expected that `indexer-agent` will create |
| 116 | +# the necessary tables. |
| 117 | +postgres_url = "postgres://postgres@postgres:5432/postgres" |
| 118 | + |
| 119 | +[graph_node] |
| 120 | +# URL to your graph-node's query endpoint |
| 121 | +query_url = "<http://graph-node:8000>" |
| 122 | +# URL to your graph-node's status endpoint |
| 123 | +status_url = "<http://graph-node:8000/graphql>" |
| 124 | + |
| 125 | +[subgraphs.network] |
| 126 | +# Query URL for the Graph Network subgraph. |
| 127 | +query_url = "<http://example.com/network-subgraph>" |
| 128 | +# Optional, deployment to look for in the local `graph-node`, if locally indexed. |
| 129 | +# Locally indexing the subgraph is recommended. |
| 130 | +# NOTE: Use `query_url` or `deployment_id` only |
| 131 | +deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 132 | + |
| 133 | +[subgraphs.escrow] |
| 134 | +# Query URL for the Escrow subgraph. |
| 135 | +query_url = "<http://example.com/network-subgraph>" |
| 136 | +# Optional, deployment to look for in the local `graph-node`, if locally indexed. |
| 137 | +# Locally indexing the subgraph is recommended. |
| 138 | +# NOTE: Use `query_url` or `deployment_id` only |
| 139 | +deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
| 140 | + |
| 141 | +[blockchain] |
| 142 | +# The chain ID of the network that the graph network is running on |
| 143 | +chain_id = 1337 |
| 144 | +# Contract address of TAP's receipt aggregate voucher (RAV) verifier. |
| 145 | +receipts_verifier_address = "0x2222222222222222222222222222222222222222" |
| 146 | + |
| 147 | +######################################## |
| 148 | +# Specific configurations to tap-agent # |
| 149 | +######################################## |
| 150 | +[tap] |
| 151 | +# This is the amount of fees you are willing to risk at any given time. For ex. |
| 152 | +# if the sender stops supplying RAVs for long enough and the fees exceed this |
| 153 | +# amount, the indexer-service will stop accepting queries from the sender |
| 154 | +# until the fees are aggregated. |
| 155 | +# NOTE: Use strings for decimal values to prevent rounding errors |
| 156 | +# e.g: |
| 157 | +# max_amount_willing_to_lose_grt = "0.1" |
| 158 | +max_amount_willing_to_lose_grt = 20 |
| 159 | + |
| 160 | +[tap.sender_aggregator_endpoints] |
| 161 | +# Key-Value of all senders and their aggregator endpoints |
| 162 | +0xdeadbeefcafebabedeadbeefcafebabedeadbeef = "https://example.com/aggregate-receipts" |
| 163 | +0x0123456789abcdef0123456789abcdef01234567 = "https://other.example.com/aggregate-receipts" |
| 164 | +``` |
| 165 | + |
| 166 | +Notes: |
| 167 | + |
| 168 | +- Values for `tap.sender_aggregator_endpoints` can be found in the [gateway section](/tap/#gateway). |
| 169 | +- Values for `blockchain.receipts_verifier_address` must be used accordingly to the [Blockchain addresses section](/tap/#contracts) using the appropriate chain id. |
| 170 | + |
| 171 | +### Running |
| 172 | + |
| 173 | +| Component | Version | Image Link | |
| 174 | +| --- | --- | --- | |
| 175 | +| indexer-service | v1.0.0-rc.6 | [indexer-service](https://github.com/graphprotocol/indexer-rs/pkgs/container/indexer-service-rs/264320627?tag=1.0.0-rc.6) | |
| 176 | +| indexer-agent | PR #995 | [indexer-agent](https://github.com/graphprotocol/indexer/pkgs/container/indexer-agent/266166026?tag=sha-d98cf80) | |
| 177 | +| tap-agent | v1.0.0-rc.6 | [tap-agent](https://github.com/graphprotocol/indexer-rs/pkgs/container/indexer-tap-agent/264320547?tag=1.0.0-rc.6) | |
| 178 | + |
| 179 | +**Command argument** |
| 180 | + |
| 181 | +With a configuration file `config.toml` setup, you can either run the following docker-image or use the config args: `--config/path/to/config.toml` |
| 182 | + |
| 183 | +**Log Level** |
| 184 | + |
| 185 | +- You can set the log level by using the `RUST_LOG` environment variable. |
| 186 | +- It’s recommended that you set it to `RUST_LOG=indexer_tap_agent=debug,info`. |
| 187 | + |
| 188 | +## Monitoring |
| 189 | + |
| 190 | +### Metrics |
| 191 | + |
| 192 | +All components expose the port 7300 to be queried by prometheus. |
| 193 | + |
| 194 | +### Grafana Dashboard |
| 195 | + |
| 196 | +You can download [Grafana Dashboard](https://github.com/graphprotocol/indexer-rs/blob/main/docs/dashboard.json) and import. |
| 197 | + |
| 198 | +### Launchpad |
| 199 | + |
| 200 | +Currently, there is a WIP version of `indexer-rs` and `tap-agent` that can be found [here](https://github.com/graphops/launchpad-charts/tree/feat/indexer-rs/charts/graph-network-indexer) |
0 commit comments