Skip to content

Commit 11992eb

Browse files
committed
fix(testing_plan): Remove code example and improve description of testing considerations
1 parent aec6096 commit 11992eb

File tree

1 file changed

+36
-112
lines changed

1 file changed

+36
-112
lines changed

rav_e2e/testing_plan.md

Lines changed: 36 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ This plan outlines how to test the complete Timeline Aggregation Protocol (TAP)
66

77
## Components Involved
88

9-
- Gateway - Sends receipts with queries
9+
- Gateway - Sends signed receipts with queries to the indexer-service
1010
- Indexer Service - Processes queries and collects receipts
11-
- TAP Agent - Manages receipts and requests RAVs
11+
- TAP Agent - Manages receipts and requests RAVs to the aggregator
1212
- Gateway Receipt Aggregator(tap-aggregator) - Aggregates receipts into RAVs
13-
- Indexer Agent - Handles redemption of RAVs(Not used directly in this test)
13+
- Indexer Agent - Handles redemption of RAVs(Not use directly for testing checks)
1414

1515
## Prerequisites
1616

1717
- All containers are running (indexer-service, tap-agent, database, graph-node, tap-aggregator, indexer-agent, gateway, graph-node and database)
1818
- Contracts deployed (graph-contracts and tap contracts)
19-
- Gateway funded with GRT and aware of indexer address(use fund_escrow.sh script)
19+
- Gateway funded with GRT and has our indexer address pre-registered thanks to an option in its configuration file. address(use fund_escrow.sh script)
2020
- An active allocation exists (or a mock allocation is used)
2121

2222
## Understanding RAV Trigger Mechanism
@@ -45,7 +45,7 @@ if !state.backoff_info.in_backoff() && total_fee_outside_buffer >= state.config.
4545

4646
The `timestamp_buffer_secs` configuration is critically important to RAV generation:
4747

48-
- Only receipts that are older than `now + timestamp_buffer_secs` are counted towards the `total_fee_outside_buffer`
48+
- Only receipts that are older than `timestamp_buffer_secs` are counted towards the `total_fee_outside_buffer`
4949
- This means if `timestamp_buffer_secs = 1000`, receipts must be at least 1000 seconds (16.7 minutes) old before they'll contribute to triggering a RAV
5050
- If you wait less than `timestamp_buffer_secs` between sending receipts and checking for RAVs, the test will fail even if you've sent enough value
5151

@@ -83,93 +83,23 @@ Common issues caused by `timestamp_buffer_secs`:
8383
### Step 2: Send Multiple Queries with Signed Receipts
8484

8585
1. Send enough queries to exceed the trigger value threshold
86-
2. With max_receipt_value_grt of 0.001 GRT and a trigger_value of 0.002 GRT, this would mean sending at least 3 receipts
86+
2. With **max_receipt_value_grt** of 0.001 GRT and a **trigger_value** of 0.002 GRT, this would mean sending at least 3 receipts
8787
3. Each query should include a properly signed TAP receipt
8888
4. Verify each query returns a successful response
8989

9090
**IMPORTANT**: Wait longer than `timestamp_buffer_secs` after sending receipts before checking for RAV generation. For example, if `timestamp_buffer_secs = 60`, wait at least 65 seconds.
9191

92-
```rust
93-
// Example code to send multiple queries with receipts
94-
async fn send_multiple_queries(http_client: &Client, gateway_url: &str, subgraph_id: &str,
95-
gateway_api_key: &str, receipt_generator: &ReceiptGenerator,
96-
num_queries: usize) -> Result<()> {
97-
// Use the maximum allowed receipt value
98-
let value_per_query = 1_000_000_000_000_000u128; // 0.001 GRT (maximum allowed)
99-
100-
// Send receipts in batches with pauses to exceed the timestamp buffer
101-
let batch_size = 50;
102-
let num_batches = (num_queries + batch_size - 1) / batch_size; // Ceiling division
103-
104-
let mut total_value = 0u128;
105-
106-
// Get the timestamp buffer from configuration or use a default
107-
let timestamp_buffer_secs = 60; // ADJUST THIS to match your actual configuration!
108-
let wait_time = timestamp_buffer_secs + 5; // Wait longer than the timestanp buffer
109-
110-
for batch in 0..num_batches {
111-
let start_idx = batch * batch_size;
112-
let end_idx = std::cmp::min((batch + 1) * batch_size, num_queries);
113-
114-
for i in start_idx..end_idx {
115-
let receipt = receipt_generator.generate_receipt(value_per_query)?;
116-
let receipt_json = serde_json::to_string(&receipt)?;
117-
118-
119-
let query_response = http_client
120-
.post(format!("{}/api/subgraphs/id/{}", gateway_url, subgraph_id))
121-
.header("Content-Type", "application/json")
122-
.header("Authorization", format!("Bearer {}", gateway_api_key))
123-
.header("Tap-Receipt", receipt_json)
124-
.json(&json!({
125-
"query": "{ _meta { block { number } } }"
126-
}))
127-
.send()
128-
.await?;
129-
130-
println!("Query {} response: {}", i+1, query_response.status());
131-
132-
total_value += value_per_query;
133-
134-
// Small delay to prevent flooding
135-
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
136-
}
137-
138-
println!("Batch {} complete, total value sent: {} GRT",
139-
batch+1,
140-
total_value as f64 / 1_000_000_000_000_000f64);
141-
142-
// Wait longer than timestamp_buffer_secs to ensure receipts are outside buffer
143-
println!("Waiting {} seconds to exceed the timestamp buffer...", wait_time);
144-
tokio::time::sleep(tokio::time::Duration::from_secs(wait_time)).await;
145-
}
146-
147-
Ok(())
148-
}
149-
```
150-
15192
### Step 3: Monitor TAP Agent Logs for Receipt Collection
15293

153-
1. Check the tap-agent logs to verify receipts are being stored
154-
2. Look for log entries that indicate the receipt has passed validation
155-
3. Look for log entries showing the calculated `total_fee_outside_buffer` value
94+
1. Check the tap-agent logs to verify receipts are being stored/generated
95+
2. Look for log entries showing the calculated `total_fee_outside_buffer` value
15696

15797
```bash
15898
# Command to monitor tap-agent logs
159-
docker logs -f tap-agent | grep -i "receipt\|rav\|trigger"
160-
```
161-
162-
### Step 4: Monitor tap-aggregator for RAV Generation
163-
164-
1. Check the tap-aggregator logs for evidence of RAV creation
165-
2. Look for log entries that mention "RAV" or "aggregation"
166-
167-
```bash
168-
# Command to monitor tap-aggregator logs
169-
docker logs -f tap-aggregator | grep -i "rav\|aggregat"
99+
docker logs -f tap-agent | grep -i "receipt\|rav"
170100
```
171101

172-
### Step 5: Monitor Metrics Endpoints (What we do here)
102+
### Step 4: Monitor Metrics Endpoints(What We do in this test)
173103

174104
Both the TAP Agent and Gateway Receipt Aggregator expose Prometheus metrics that can help verify the flow:
175105

@@ -182,11 +112,20 @@ curl http://localhost:7300/metrics | grep -i "tap_unaggregated_fees\|tap_rav"
182112
curl http://localhost:7700/metrics | grep -i "rav"
183113
```
184114

185-
Pay particular attention to metrics showing the actual accumulated value outside the buffer:
115+
Pay attention to metrics showing the actual accumulated value outside the buffer:
186116

187117
- `tap_unaggregated_fees_grt_total` - Shows total unaggregated fees (including those inside buffer)
188118
- `tap_rav_request_trigger_value` - Shows the configured trigger value threshold
189119

120+
Changes on those values are an indication that receipts are being processed and probably RAVs are being requested.
121+
122+
### Step 5: (Optional) Test RAV Redemption
123+
124+
1. Monitor indexer-agent logs for RAV redemption activity
125+
2. Check on-chain transactions for successful redemption
126+
127+
Here we could monitor or make calls to a smart contract to retrieve this information basing on sender address.
128+
190129
## Configuration Tips
191130

192131
### TAP Agent Configuration
@@ -204,14 +143,10 @@ max_amount_willing_to_lose_grt = 1000 # Can be 20 or 1000 depending on config
204143

205144
[tap.rav_request]
206145
# Determines the trigger threshold: max_amount_willing_to_lose_grt / trigger_value_divisor
207-
# With max_amount_willing_to_lose_grt=1000, gives 0.002 GRT trigger
208-
trigger_value_divisor = 500_000
146+
trigger_value_divisor = 500_000 # With max_amount_willing_to_lose_grt=1000, gives 0.002 GRT trigger
209147

210148
# ⚠️ CRITICAL: Buffer period for receipts (in seconds)
211-
# Should NOT be 1000 for testing!
212-
# The higher the value, the higher the number
213-
# of receipts and the longer the wait time
214-
timestamp_buffer_secs = 60
149+
timestamp_buffer_secs = 60 # Should NOT be 1000 for testing!
215150

216151
# Timeout for RAV requests (in seconds)
217152
request_timeout_secs = 5
@@ -220,6 +155,8 @@ request_timeout_secs = 5
220155
max_receipts_per_request = 10000
221156
```
222157

158+
This configuration is located in `contrib/tap-agent/config.toml`
159+
223160
### Modifying Configuration for Testing
224161

225162
For practical testing purposes, adjust these values:
@@ -245,33 +182,20 @@ trigger_value_divisor = 500_000 # Makes trigger_value = 0.002 GRT
245182
timestamp_buffer_secs = 60 # Receipts must be 60 seconds old to count
246183
```
247184

248-
## Troubleshooting
249-
250-
### Timestamp Buffer Issues
251-
252-
- **Most common issue**: Waiting less time than `timestamp_buffer_secs` after sending receipts
253-
- Check for log entries mentioning `total_fee_outside_buffer` to see what value is actually being compared against the trigger
254-
- Verify your test waits at least `timestamp_buffer_secs + 5` seconds after sending receipts
255-
- Consider temporarily reducing `timestamp_buffer_secs` if your test environment has it set too high (e.g., 1000 seconds)
256-
257-
### Value-Based Trigger Issues
258-
259-
- Calculate your actual trigger threshold using `max_amount_willing_to_lose_grt / trigger_value_divisor`
260-
- Check metrics with `curl http://localhost:7300/metrics | grep tap_rav_request_trigger_value` to confirm
261-
- Ensure you're sending enough total value to exceed this threshold
262-
- Remember that each receipt value is limited by `max_receipt_value_grt` (typically 0.001 GRT)
185+
### Note on throughput testing
263186

264-
### Other Common Issues
187+
1. High-Volume Testing Setup - How to configure the system for throughput testing by:
265188

266-
- Verify the allocation ID is valid and active
267-
- Check for backoff conditions in the logs that might prevent RAV requests
268-
- Verify the Gateway is properly funded with enough GRT
269-
- Check if the Indexer or Gateway are experiencing any errors in the logs
189+
- Lowering the timestamp buffer to allow rapid receipt processing, in the sense that now a higher number of receipts
190+
must be sent in a shorter period of time.
191+
- Increasing the trigger value to require more receipts before RAV generation
192+
- Monitoring system resources during the test
270193

271-
### Monitoring Key Metrics
194+
2. Stress Testing Variations - Different configuration patterns for testing various aspects:
272195

273-
Monitor these metrics during testing:
196+
- High frequency, low value receipts
197+
- High value, low frequency receipts
198+
- Burst traffic patterns
274199

275-
- `tap_rav_request_trigger_value` - The calculated trigger threshold
276-
- `tap_unaggregated_fees_grt_total` - Total unaggregated fees (including those in buffer)
277-
- `tap_rav_request_total` - Total number of RAV requests made
200+
But You need to be aware of some limits the protocol imposes, for example there is a maximum receipt amount
201+
configuration, otherwise receipt is not processed.

0 commit comments

Comments
 (0)