Skip to content

Commit 58c3c13

Browse files
committed
docs: update GraphTally docs
Signed-off-by: Joseph Livesey <[email protected]>
1 parent b83b32c commit 58c3c13

File tree

1 file changed

+222
-99
lines changed
  • website/src/pages/en/indexing

1 file changed

+222
-99
lines changed

website/src/pages/en/indexing/tap.mdx

Lines changed: 222 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: GraphTally Guide
33
---
44

5-
Learn about The Graphs new payment system, **GraphTally** [(previously Timeline Aggregation Protocol)](https://docs.rs/tap_core/latest/tap_core/index.html). This system provides fast, efficient microtransactions with minimized trust.
5+
Learn about The Graph's new payment system, **GraphTally** [(previously Timeline Aggregation Protocol)](https://docs.rs/tap_core/latest/tap_core/index.html). This system provides fast, efficient microtransactions with minimized trust.
66

77
## Overview
88

@@ -11,34 +11,30 @@ GraphTally is a drop-in replacement to the Scalar payment system currently in pl
1111
- Efficiently handles micropayments.
1212
- Adds a layer of consolidations to onchain transactions and costs.
1313
- 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.
14+
- Enables decentralized, trustless gateways and improves indexer service performance for multiple senders.
1515

16-
### Specifics
16+
### How It Works
1717

18-
GraphTally allows a sender to make multiple payments to a receiver, **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.
18+
GraphTally allows a sender to make multiple payments to a receiver through **Receipts**, which are then aggregated into a single payment called a **Receipt Aggregate Voucher (RAV)**. This aggregated payment can be verified on the blockchain, reducing the number of transactions and simplifying the payment process.
1919

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.
20+
For each query, the gateway sends a signed receipt that is stored in your database. The `indexer-tap-agent` aggregates these receipts into RAVs through periodic requests. You can update a RAV by sending it with newer receipts, which generates a new RAV with an increased value.
2121

2222
### RAV Details
2323

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-
24+
- RAVs represent money waiting to be sent to the blockchain.
25+
- The system continuously aggregates receipts to ensure that the total value of non-aggregated receipts does not exceed the configured `max_amount_willing_to_lose_grt`.
2826
- Each RAV can be redeemed once in the contracts, which is why they are sent after the allocation is closed.
2927

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:
28+
### Redeeming RAVs
3329

34-
1. An Indexer closes allocation.
30+
The redemption process is fully automated when running both `indexer-tap-agent` and `indexer-agent`:
3531

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-
- If it was reverted, the RAV is resent to the blockchain. If it was not reverted, it gets marked as `final`.
32+
1. An Indexer closes an allocation.
33+
2. After the `recently-closed-allocation-buffer` period, `indexer-tap-agent` takes all pending receipts for that allocation and requests aggregation into a final RAV, marking it as `last`.
34+
3. `indexer-agent` takes all the last RAVs and sends redeem requests to the blockchain, updating the `redeem_at` value.
35+
4. During the `finality-time` period, `indexer-agent` monitors for blockchain reorganizations:
36+
- If the transaction was reverted, the RAV is resent to the blockchain.
37+
- If not reverted, it gets marked as `final`.
4238

4339
## Blockchain Addresses
4440

@@ -58,132 +54,259 @@ As long as you run `tap-agent` and `indexer-agent`, everything will be executed
5854
| Signers | `0xfF4B7A5EfD00Ff2EC3518D4F250A27e4c29A2211` | `0xFb142dE83E261e43a81e9ACEADd1c66A0DB121FE` |
5955
| Aggregator | `https://tap-aggregator.network.thegraph.com` | `https://tap-aggregator.testnet.thegraph.com` |
6056

61-
### Prerequisites
57+
## Prerequisites
6258

63-
In addition to the typical requirements to run an indexer, youll need a `tap-escrow-subgraph` endpoint to query updates. You can use The Graph Network to query or host yourself on your `graph-node`.
59+
In addition to typical indexer requirements, you'll need a `tap-escrow-subgraph` endpoint to query escrow information. You can use The Graph Network to query or self-host on your `graph-node`:
6460

6561
- [Graph TAP Arbitrum Sepolia Subgraph (for The Graph testnet)](https://thegraph.com/explorer/subgraphs/7ubx365MiqBH5iUz6XWXWT8PTof5BVAyEzdb8m17RvbD)
6662
- [Graph TAP Arbitrum One Subgraph (for The Graph mainnet)](https://thegraph.com/explorer/subgraphs/4sukbNVTzGELnhdnpyPqsf1QqtzNHEYKKmJkgaT8z6M1)
6763

68-
> Note: `indexer-agent` does not currently handle the indexing of this Subgraph like it does for the network Subgraph deployment. As a result, you have to index it manually.
64+
> Note: `indexer-agent` does not currently handle the indexing of this Subgraph like it does for the Network Subgraph deployment. You must index it manually.
6965
7066
## Migration Guide
7167

72-
### Software versions
68+
### Software Requirements
7369

74-
The required software version can be found [here](https://github.com/graphprotocol/indexer/blob/main/docs/networks/arbitrum-one.md#latest-releases).
70+
#### Required Versions
7571

76-
### Steps
72+
- **indexer-agent**: [Latest version supporting TAP](https://github.com/graphprotocol/indexer/releases)
73+
- **indexer-service-rs**: [Latest release](https://github.com/graphprotocol/indexer-rs/releases?q=indexer-service-rs)
74+
- **indexer-tap-agent**: [Latest release](https://github.com/graphprotocol/indexer-rs/releases?q=indexer-tap-agent)
7775

78-
1. **Indexer Agent**
79-
- Follow the [same process](https://github.com/graphprotocol/indexer/pkgs/container/indexer-agent#graph-protocol-indexer-components).
80-
- Give the new argument `--tap-subgraph-endpoint` to activate the new GraphTally codepaths and enable redeeming of RAVs.
76+
#### Docker Images
8177

82-
2. **Indexer Service**
83-
- Fully replace your current configuration with the [new Indexer Service rs](https://github.com/graphprotocol/indexer-rs). It's recommend that you use the [container image](https://github.com/orgs/graphprotocol/packages?repo_name=indexer-rs).
84-
- Like the older version, you can scale Indexer Service horizontally easily. It is still stateless.
78+
```bash
79+
# Indexer Service
80+
docker pull ghcr.io/graphprotocol/indexer-service-rs:latest
8581

86-
3. **TAP Agent**
87-
- Run _one_ single instance of [TAP Agent](https://github.com/graphprotocol/indexer-rs) at all times. It's recommend that you use the [container image](https://github.com/orgs/graphprotocol/packages?repo_name=indexer-rs).
82+
# TAP Agent
83+
docker pull ghcr.io/graphprotocol/indexer-tap-agent:latest
84+
```
8885

89-
4. **Configure Indexer Service and TAP Agent**
86+
### Migration Steps
9087

91-
Configuration is a TOML file shared between `indexer-service` and `tap-agent`, supplied with the argument `--config /path/to/config.toml`.
88+
#### 1. Update Indexer Agent
9289

93-
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)
90+
- Continue using your existing `indexer-agent`
91+
- Add the `--tap-subgraph-endpoint` argument to enable TAP functionality and RAV redemption
92+
- Example: `--tap-subgraph-endpoint https://api.thegraph.com/subgraphs/name/graphprotocol/tap-mainnet`
9493

95-
For minimal configuration, use the following template:
94+
#### 2. Replace Indexer Service
9695

97-
```bash
98-
# You will have to change *all* the values below to match your setup.
99-
#
100-
# Some of the config below are global graph network values, which you can find here:
101-
# <https://github.com/graphprotocol/indexer/tree/main/docs/networks>
102-
#
103-
# Pro tip: if you need to load some values from the environment into this config, you
104-
# can overwrite with environment variables. For example, the following can be replaced
105-
# by [PREFIX]_DATABASE_POSTGRESURL, where PREFIX can be `INDEXER_SERVICE` or `TAP_AGENT`:
106-
#
107-
# [database]
108-
# postgres_url = "postgresql://indexer:${POSTGRES_PASSWORD}@postgres:5432/indexer_components_0"
96+
- Fully replace your TypeScript indexer-service with `indexer-service-rs`
97+
- The new service is stateless and can be scaled horizontally
98+
- Use the same database as your existing setup
99+
100+
#### 3. Deploy TAP Agent
101+
102+
- Run exactly **one instance** of `indexer-tap-agent`
103+
- This component manages receipt aggregation and RAV creation
104+
- It must have access to the same database as other indexer components
105+
106+
#### 4. Configuration
107+
108+
Both `indexer-service-rs` and `indexer-tap-agent` share a TOML configuration file. Create a configuration file and pass it with `--config /path/to/config.toml`.
109+
110+
##### Minimal Configuration Example
111+
112+
```toml
113+
# Essential configuration for indexer-rs components
114+
# All values below must be updated to match your setup
109115

110116
[indexer]
111117
indexer_address = "0x1111111111111111111111111111111111111111"
112-
operator_mnemonic = "celery smart tip orange scare van steel radio dragon joy alarm crane"
118+
operator_mnemonic = "your twelve word mnemonic phrase here ..."
113119

114120
[database]
115-
# The URL of the Postgres database used for the indexer components. The same database
116-
# that is used by the `indexer-agent`. It is expected that `indexer-agent` will create
117-
# the necessary tables.
118-
postgres_url = "postgres://postgres@postgres:5432/postgres"
121+
# Use the same database as your indexer-agent
122+
postgres_url = "postgresql://user:password@localhost:5432/indexer_db"
119123

120124
[graph_node]
121-
# URL to your graph-node's query endpoint
122-
query_url = "<http://graph-node:8000>"
123-
# URL to your graph-node's status endpoint
124-
status_url = "<http://graph-node:8000/graphql>"
125+
# Your graph-node endpoints
126+
query_url = "http://graph-node:8000"
127+
status_url = "http://graph-node:8000/graphql"
125128

126129
[subgraphs.network]
127-
# Query URL for the Graph Network Subgraph.
128-
query_url = "<http://example.com/network-subgraph>"
129-
# Optional, deployment to look for in the local `graph-node`, if locally indexed.
130-
# Locally indexing the Subgraph is recommended.
131-
# NOTE: Use `query_url` or `deployment_id` only
132-
deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
130+
# The Graph Network Subgraph (use query_url OR deployment_id, not both)
131+
query_url = "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-arbitrum"
132+
# deployment_id = "QmUVskWrz1ZiQZ76AtyhcfFDEH1ELnRpoyEhVL8p6NFTbR"
133133

134134
[subgraphs.escrow]
135-
# Query URL for the Escrow Subgraph.
136-
query_url = "<http://example.com/network-subgraph>"
137-
# Optional, deployment to look for in the local `graph-node`, if locally indexed.
138-
# Locally indexing the Subgraph is recommended.
139-
# NOTE: Use `query_url` or `deployment_id` only
140-
deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
135+
# TAP Escrow Subgraph (use query_url OR deployment_id, not both)
136+
query_url = "https://api.thegraph.com/subgraphs/name/graphprotocol/tap-arbitrum-one"
137+
# deployment_id = "QmPcbDomKwfsmVBNbvncU8gdWTvUiH9zVFYxDMc5ohpjvU"
141138

142139
[blockchain]
143-
# The chain ID of the network that the graph network is running on
144-
chain_id = 1337
145-
# Contract address of TAP's receipt aggregate voucher (RAV) verifier.
146-
receipts_verifier_address = "0x2222222222222222222222222222222222222222"
147-
148-
########################################
149-
# Specific configurations to tap-agent #
150-
########################################
140+
# For Arbitrum mainnet
141+
chain_id = 42161
142+
receipts_verifier_address = "0x33f9E93266ce0E108fc85DdE2f71dab555A0F05a"
143+
144+
# For Arbitrum Sepolia testnet, use:
145+
# chain_id = 421614
146+
# receipts_verifier_address = "0xfC24cE7a4428A6B89B52645243662A02BA734ECF"
147+
151148
[tap]
152-
# This is the amount of fees you are willing to risk at any given time. For ex.
153-
# if the sender stops supplying RAVs for long enough and the fees exceed this
154-
# amount, the indexer-service will stop accepting queries from the sender
155-
# until the fees are aggregated.
156-
# NOTE: Use strings for decimal values to prevent rounding errors
157-
# e.g:
158-
# max_amount_willing_to_lose_grt = "0.1"
159-
max_amount_willing_to_lose_grt = 20
149+
# Maximum GRT amount to risk before requiring aggregation
150+
# Use string format to prevent rounding errors
151+
max_amount_willing_to_lose_grt = "0.1"
160152

161153
[tap.sender_aggregator_endpoints]
162-
# Key-Value of all senders and their aggregator endpoints
163-
# This one below is for the E&N testnet gateway for example.
164-
0xDDE4cfFd3D9052A9cb618fC05a1Cd02be1f2F467 = "https://tap-aggregator.network.thegraph.com"
154+
# Gateway endpoints for RAV aggregation
155+
# Mainnet
156+
"0xDDE4cfFd3D9052A9cb618fC05a1Cd02be1f2F467" = "https://tap-aggregator.network.thegraph.com"
157+
158+
# For testnet, use:
159+
# "0xC3dDf37906724732FfD748057FEBe23379b0710D" = "https://tap-aggregator.testnet.thegraph.com"
165160
```
166161

167-
Notes:
162+
##### Environment Variable Overrides
163+
164+
You can override any configuration value using environment variables:
168165

169-
- Values for `tap.sender_aggregator_endpoints` can be found in the [gateway section](/indexing/tap/#gateway).
170-
- Values for `blockchain.receipts_verifier_address` must be used accordingly to the [Blockchain addresses section](/indexing/tap/#contracts) using the appropriate chain id.
166+
```bash
167+
# Pattern: [PREFIX]__[SECTION]__[KEY]
168+
# PREFIX can be INDEXER_SERVICE or TAP_AGENT
169+
170+
# Examples:
171+
export INDEXER_SERVICE__DATABASE__POSTGRES_URL="postgresql://..."
172+
export TAP_AGENT__TAP__MAX_AMOUNT_WILLING_TO_LOSE_GRT="0.5"
173+
export INDEXER_SERVICE__BLOCKCHAIN__RECEIPTS_VERIFIER_ADDRESS="0x..."
174+
```
171175

172-
**Log Level**
176+
##### Advanced Configuration
173177

174-
- You can set the log level by using the `RUST_LOG` environment variable.
175-
- It’s recommended that you set it to `RUST_LOG=indexer_tap_agent=debug,info`.
178+
For all configuration options, see:
179+
180+
- [Full configuration example](https://github.com/graphprotocol/indexer-rs/blob/main/crates/config/maximal-config-example.toml)
181+
- [Default values](https://github.com/graphprotocol/indexer-rs/blob/main/crates/config/default_values.toml)
182+
183+
### Logging
184+
185+
Set the log level using the `RUST_LOG` environment variable:
186+
187+
```bash
188+
# Recommended for production
189+
export RUST_LOG=indexer_service=info,indexer_tap_agent=info
190+
191+
# For debugging
192+
export RUST_LOG=indexer_service=debug,indexer_tap_agent=debug
193+
194+
# TAP-specific debugging
195+
export RUST_LOG=indexer_tap_agent=debug,info
196+
```
176197

177198
## Monitoring
178199

179200
### Metrics
180201

181-
All components expose the port 7300 to be queried by prometheus.
202+
All components expose Prometheus metrics on port 7300:
203+
204+
- `http://indexer-service:7300/metrics`
205+
- `http://tap-agent:7300/metrics`
206+
207+
Key metrics to monitor:
208+
209+
- **Receipt Processing**: Track receipt validation, aggregation rates, and failures
210+
- **RAV Creation**: Monitor RAV request success/failure rates
211+
- **Unaggregated Fees**: Ensure fees stay below `max_amount_willing_to_lose_grt`
212+
- **Sender Balances**: Track escrow account balances and obligations
182213

183214
### Grafana Dashboard
184215

185-
You can download [Grafana Dashboard](https://github.com/graphprotocol/indexer-rs/blob/main/docs/dashboard.json) and import.
216+
Import the [official Grafana dashboard](https://github.com/graphprotocol/indexer-rs/blob/main/docs/dashboard.json) for comprehensive monitoring of:
217+
218+
- TAP receipt flow and aggregation status
219+
- RAV creation and redemption lifecycle
220+
- System performance and error rates
221+
- Database query performance
222+
223+
### Troubleshooting
224+
225+
Common issues and solutions:
226+
227+
1. **RAV requests failing**:
228+
- Check aggregator endpoint connectivity
229+
- Verify sender configuration in `tap.sender_aggregator_endpoints`
230+
- Review debug logs for specific error messages
231+
232+
2. **Receipts not aggregating**:
233+
- Ensure `tap-agent` is running (only one instance)
234+
- Check database connectivity
235+
- Verify `max_amount_willing_to_lose_grt` is not too high
236+
237+
3. **High unaggregated fees**:
238+
- Lower `max_amount_willing_to_lose_grt` to trigger more frequent aggregation
239+
- Check if specific senders are having aggregation issues
240+
- Monitor the Grafana dashboard for aggregation patterns
241+
242+
## Deployment Options
243+
244+
### Docker Compose
245+
246+
Example compose configuration for both services:
247+
248+
```yaml
249+
version: '3.8'
250+
251+
services:
252+
indexer-service:
253+
image: ghcr.io/graphprotocol/indexer-service-rs:latest
254+
ports:
255+
- '7600:7600' # Service port
256+
- '7300:7300' # Metrics port
257+
volumes:
258+
- ./config.toml:/config.toml
259+
command: ['--config', '/config.toml']
260+
environment:
261+
- RUST_LOG=indexer_service=info
262+
restart: unless-stopped
263+
264+
tap-agent:
265+
image: ghcr.io/graphprotocol/indexer-tap-agent:latest
266+
ports:
267+
- '7301:7300' # Metrics port (different host port)
268+
volumes:
269+
- ./config.toml:/config.toml
270+
command: ['--config', '/config.toml']
271+
environment:
272+
- RUST_LOG=indexer_tap_agent=info
273+
restart: unless-stopped
274+
```
275+
276+
### Kubernetes
277+
278+
For Kubernetes deployments, see the [Graph Launchpad charts](https://github.com/graphops/launchpad-charts/tree/main/charts/graph-network-indexer) which include:
279+
280+
- Helm charts for both services
281+
- ConfigMap templates for configuration
282+
- Service and ingress definitions
283+
- Prometheus ServiceMonitor resources
284+
285+
## Best Practices
286+
287+
1. **Database Performance**:
288+
- Ensure your PostgreSQL instance has adequate resources
289+
- Monitor query performance through metrics
290+
- Regular maintenance of receipt tables
291+
292+
2. **High Availability**:
293+
- Run multiple `indexer-service-rs` instances behind a load balancer
294+
- Keep `tap-agent` as a single instance with proper monitoring
295+
- Use database connection pooling
296+
297+
3. **Security**:
298+
- Store operator mnemonic securely (use environment variables)
299+
- Restrict database access to indexer components only
300+
- Monitor for unusual receipt patterns
301+
302+
4. **Capacity Planning**:
303+
- Monitor receipt growth rate
304+
- Plan database storage accordingly
305+
- Set appropriate `max_amount_willing_to_lose_grt` based on query volume
186306

187-
### Launchpad
307+
## Additional Resources
188308

189-
Currently, there is a WIP version of `indexer-rs` and `tap-agent` that can be found [here](https://github.com/graphops/launchpad-charts/tree/main/charts/graph-network-indexer)
309+
- [indexer-rs Repository](https://github.com/graphprotocol/indexer-rs)
310+
- [TAP Core Documentation](https://docs.rs/tap_core/latest/tap_core/)
311+
- [The Graph Discord](https://thegraph.com/discord) - Get help in the #indexers channel
312+
- [Support](https://github.com/graphprotocol/indexer-rs/issues) - Report issues or get help

0 commit comments

Comments
 (0)