Skip to content

Commit 151383b

Browse files
committed
refactor: configure system for transition mode
Signed-off-by: Joseph Livesey <[email protected]>
1 parent 8c06699 commit 151383b

File tree

11 files changed

+436
-92
lines changed

11 files changed

+436
-92
lines changed

contrib/indexer-service/config.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ status_url = "http://graph-node:8030/graphql"
1212
[subgraphs.network]
1313
query_url = "http://graph-node:8000/subgraphs/name/graph-network"
1414
deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"
15+
syncing_interval_secs = 30
16+
recently_closed_allocation_buffer_secs = 60
1517

1618
[subgraphs.escrow]
1719
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
1820
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
21+
syncing_interval_secs = 30
22+
23+
[subgraphs.escrow_v2]
24+
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25+
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26+
syncing_interval_secs = 30
1927

2028
[blockchain]
2129
chain_id = 1337
@@ -46,4 +54,8 @@ trigger_value_divisor = 500_000
4654
"ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610"
4755

4856
[horizon]
49-
enabled = true
57+
# Horizon migration mode: legacy | transition | full
58+
# - legacy: Only v1 TAP receipts supported (pre-migration)
59+
# - transition: Both v1 and v2 TAP receipts supported (during migration)
60+
# - full: Only v2 TAP receipts supported (post-migration)
61+
mode = "transition"

contrib/indexer-service/start.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@ if [ "$ESCROW_DEPLOYMENT" = "null" ] || [ -z "$ESCROW_DEPLOYMENT" ]; then
3939
ESCROW_DEPLOYMENT=""
4040
fi
4141

42+
# Get escrow v2 subgraph deployment ID
43+
stdbuf -oL echo "🔍 DEBUG: Fetching escrow v2 subgraph deployment ID..."
44+
ESCROW_V2_DEPLOYMENT=$(curl -s --max-time 10 "http://graph-node:8000/subgraphs/name/semiotic/tap-v2" \
45+
-H 'content-type: application/json' \
46+
-d '{"query": "{ _meta { deployment } }"}' | jq -r '.data._meta.deployment' 2>/dev/null)
47+
stdbuf -oL echo "🔍 DEBUG: Escrow v2 deployment result: $ESCROW_V2_DEPLOYMENT"
48+
49+
# Handle null deployment IDs for v2
50+
if [ "$ESCROW_V2_DEPLOYMENT" = "null" ] || [ -z "$ESCROW_V2_DEPLOYMENT" ]; then
51+
ESCROW_V2_DEPLOYMENT=""
52+
fi
53+
4254
stdbuf -oL echo "Escrow subgraph deployment ID: $ESCROW_DEPLOYMENT"
55+
stdbuf -oL echo "Escrow v2 subgraph deployment ID: $ESCROW_V2_DEPLOYMENT"
4356
stdbuf -oL echo "Using test Network subgraph deployment ID: $NETWORK_DEPLOYMENT"
4457
stdbuf -oL echo "Using test Verifier address: $VERIFIER_ADDRESS"
4558
stdbuf -oL echo "Using test Indexer address: $RECEIVER_ADDRESS"
@@ -63,6 +76,13 @@ else
6376
# Remove the deployment_id line entirely for escrow subgraph
6477
sed -i '/deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"/d' /opt/config.toml
6578
fi
79+
80+
if [ -n "$ESCROW_V2_DEPLOYMENT" ]; then
81+
sed -i "s/ESCROW_V2_DEPLOYMENT_PLACEHOLDER/$ESCROW_V2_DEPLOYMENT/g" /opt/config.toml
82+
else
83+
# Remove the escrow_v2 section if deployment not found
84+
sed -i '/\[subgraphs.escrow_v2\]/,/^$/d' /opt/config.toml
85+
fi
6686
sed -i "s/VERIFIER_ADDRESS_PLACEHOLDER/$VERIFIER_ADDRESS/g" /opt/config.toml
6787
sed -i "s/INDEXER_ADDRESS_PLACEHOLDER/$RECEIVER_ADDRESS/g" /opt/config.toml
6888
sed -i "s/INDEXER_MNEMONIC_PLACEHOLDER/$INDEXER_MNEMONIC/g" /opt/config.toml

contrib/tap-agent/config.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ status_url = "http://graph-node:8030/graphql"
1212
[subgraphs.network]
1313
query_url = "http://graph-node:8000/subgraphs/name/graph-network"
1414
deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"
15+
syncing_interval_secs = 30
16+
recently_closed_allocation_buffer_secs = 60
1517

1618
[subgraphs.escrow]
1719
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
1820
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
21+
syncing_interval_secs = 30
22+
23+
[subgraphs.escrow_v2]
24+
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25+
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26+
syncing_interval_secs = 30
1927

2028
[blockchain]
2129
chain_id = 1337
@@ -46,4 +54,8 @@ trigger_value_divisor = 500_000
4654
"ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610"
4755

4856
[horizon]
49-
enabled = true
57+
# Horizon migration mode: legacy | transition | full
58+
# - legacy: Only v1 TAP receipts supported (pre-migration)
59+
# - transition: Both v1 and v2 TAP receipts supported (during migration)
60+
# - full: Only v2 TAP receipts supported (post-migration)
61+
mode = "transition"

contrib/tap-agent/start.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,43 @@ fi
105105

106106
echo "Escrow subgraph deployment ID: $ESCROW_DEPLOYMENT"
107107

108+
# Get escrow v2 subgraph deployment ID with retries
109+
echo "Getting escrow v2 subgraph deployment ID..."
110+
MAX_ATTEMPTS=30
111+
ATTEMPT=0
112+
ESCROW_V2_DEPLOYMENT=""
113+
114+
while [ -z "$ESCROW_V2_DEPLOYMENT" ] || [ "$ESCROW_V2_DEPLOYMENT" = "null" ] && [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
115+
ESCROW_V2_DEPLOYMENT=$(curl -s "http://graph-node:8000/subgraphs/name/semiotic/tap-v2" \
116+
-H 'content-type: application/json' \
117+
-d '{"query": "{ _meta { deployment } }"}' | jq -r '.data._meta.deployment' 2>/dev/null)
118+
119+
if [ -z "$ESCROW_V2_DEPLOYMENT" ] || [ "$ESCROW_V2_DEPLOYMENT" = "null" ]; then
120+
ATTEMPT=$((ATTEMPT + 1))
121+
echo "Waiting for escrow v2 subgraph to be deployed... Attempt $ATTEMPT/$MAX_ATTEMPTS"
122+
sleep 5
123+
fi
124+
done
125+
126+
if [ -z "$ESCROW_V2_DEPLOYMENT" ] || [ "$ESCROW_V2_DEPLOYMENT" = "null" ]; then
127+
echo "WARNING: Failed to get escrow v2 subgraph deployment ID after $MAX_ATTEMPTS attempts"
128+
# Continue without v2 for backward compatibility
129+
else
130+
echo "Escrow v2 subgraph deployment ID: $ESCROW_V2_DEPLOYMENT"
131+
fi
132+
108133
# Copy the config template
109134
cp /opt/config/config.toml /opt/config.toml
110135

111136
# Replace the placeholders with actual values
112137
sed -i "s/NETWORK_DEPLOYMENT_PLACEHOLDER/$NETWORK_DEPLOYMENT/g" /opt/config.toml
113138
sed -i "s/ESCROW_DEPLOYMENT_PLACEHOLDER/$ESCROW_DEPLOYMENT/g" /opt/config.toml
139+
if [ ! -z "$ESCROW_V2_DEPLOYMENT" ] && [ "$ESCROW_V2_DEPLOYMENT" != "null" ]; then
140+
sed -i "s/ESCROW_V2_DEPLOYMENT_PLACEHOLDER/$ESCROW_V2_DEPLOYMENT/g" /opt/config.toml
141+
else
142+
# Remove the escrow_v2 section if deployment not found
143+
sed -i '/\[subgraphs.escrow_v2\]/,/^$/d' /opt/config.toml
144+
fi
114145
sed -i "s/VERIFIER_ADDRESS_PLACEHOLDER/$VERIFIER_ADDRESS/g" /opt/config.toml
115146
sed -i "s/INDEXER_ADDRESS_PLACEHOLDER/$RECEIVER_ADDRESS/g" /opt/config.toml
116147
sed -i "s/INDEXER_MNEMONIC_PLACEHOLDER/$INDEXER_MNEMONIC/g" /opt/config.toml

crates/config/maximal-config-example.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ recently_closed_allocation_buffer_secs = 3600
6767

6868
[subgraphs.escrow]
6969
# NOTE: It is heavily recomended to use both `query_url` and `deployment_id`,
70-
# Query URL for the Escrow subgraph.
71-
query_url = "http://example.com/network-subgraph"
70+
# Query URL for the Escrow subgraph (v1).
71+
query_url = "http://example.com/escrow-subgraph"
7272
# Optional, Auth token will used a "bearer auth"
7373
# query_auth_token = "super-secret"
7474

@@ -78,6 +78,14 @@ deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
7878
# Refreshing interval for the Escrow contracts information from the Escrow subgraph.
7979
syncing_interval_secs = 60
8080

81+
[subgraphs.escrow_v2]
82+
# Query URL for the Escrow v2 subgraph (Horizon).
83+
query_url = "http://example.com/escrow-v2-subgraph"
84+
# Optional, Auth token will used a "bearer auth"
85+
# query_auth_token = "super-secret"
86+
# Refreshing interval for the Escrow v2 contracts information.
87+
syncing_interval_secs = 30
88+
8189
[blockchain]
8290
# The chain ID of the network that the graph network is running on
8391
chain_id = 1337
@@ -170,4 +178,4 @@ hardhat = "100"
170178
"eip155:1337" = "hardhat"
171179

172180
[horizon]
173-
enabled = false
181+
mode = "transition"

crates/config/minimal-config-example.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@ query_url = "http://example.com/network-subgraph"
4242
deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
4343

4444
[subgraphs.escrow]
45-
# Query URL for the Escrow subgraph.
46-
query_url = "http://example.com/network-subgraph"
45+
# Query URL for the Escrow subgraph (v1).
46+
query_url = "http://example.com/escrow-subgraph"
4747
# Optional, deployment to look for in the local `graph-node`, if locally indexed.
4848
# Locally indexing the subgraph is recommended.
4949
# NOTE: Use `query_url` or `deployment_id` only
5050
deployment_id = "Qmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
5151

52+
[subgraphs.escrow_v2]
53+
# Query URL for the Escrow v2 subgraph (Horizon).
54+
query_url = "http://example.com/escrow-v2-subgraph"
55+
syncing_interval_secs = 30
56+
5257
[blockchain]
5358
# The chain ID of the network that the graph network is running on
5459
chain_id = 1337
@@ -63,3 +68,6 @@ receipts_verifier_address = "0x2222222222222222222222222222222222222222"
6368
# Key-Value of all senders and their aggregator endpoints
6469
0xDDE4cfFd3D9052A9cb618fC05a1Cd02be1f2F467 = "https://tap-aggregator.network.thegraph.com"
6570
0xDD6a6f76eb36B873C1C184e8b9b9e762FE216490 = "https://tap-aggregator-arbitrum-one.graphops.xyz"
71+
72+
[horizon]
73+
mode = "transition"

crates/config/src/config.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ impl MetricsConfig {
303303
pub struct SubgraphsConfig {
304304
pub network: NetworkSubgraphConfig,
305305
pub escrow: EscrowSubgraphConfig,
306+
pub escrow_v2: Option<EscrowSubgraphConfig>,
306307
}
307308

308309
#[serde_as]
@@ -446,13 +447,26 @@ pub struct RavRequestConfig {
446447
pub max_receipts_per_request: u64,
447448
}
448449

450+
/// Horizon upgrade mode configuration
451+
#[derive(Debug, Clone, Deserialize, PartialEq, Default)]
452+
#[serde(rename_all = "lowercase")]
453+
pub enum HorizonMode {
454+
/// Legacy mode: Only v1 TAP receipts supported
455+
#[default]
456+
Legacy,
457+
/// Transition mode: Both v1 and v2 TAP receipts supported (for migration)
458+
Transition,
459+
/// Full mode: Only v2 TAP receipts supported (post-migration)
460+
Full,
461+
}
462+
449463
/// Configuration for the horizon
450464
/// standard
451465
#[derive(Debug, Default, Deserialize)]
452466
#[cfg_attr(test, derive(PartialEq))]
453467
pub struct HorizonConfig {
454-
/// Whether the horizon is enabled or not
455-
pub enabled: bool,
468+
/// Horizon upgrade mode
469+
pub mode: HorizonMode,
456470
}
457471

458472
#[cfg(test)]

0 commit comments

Comments
 (0)