Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ COMPOSE_PROFILES=block-oracle,explorer

# indexer components versions
GRAPH_NODE_VERSION=v0.42.1
INDEXER_AGENT_VERSION=v0.25.9
INDEXER_AGENT_VERSION=v0.25.10
INDEXER_SERVICE_RS_VERSION=v2.1.0
INDEXER_TAP_AGENT_VERSION=v2.1.0

Expand All @@ -53,8 +53,6 @@ ELIGIBILITY_ORACLE_COMMIT=84710857394d3419f83dcbf6687a91f415cc1625
BLOCK_ORACLE_COMMIT=3a3a425ff96130c3842cee7e43d06bbe3d729aed
CONTRACTS_COMMIT=511cd70563593122f556c7b35469ec185574769a
NETWORK_SUBGRAPH_COMMIT=5b6c22089a2e55db16586a19cbf6e1d73a93c7b9
TAP_CONTRACTS_COMMIT=e3351e70b3e5d9821bc0aaa90bb2173ca2a77af7
TAP_SUBGRAPH_COMMIT=cf7279f60433bf9a9d897ec2548c13c0607234cc

# service ports
CHAIN_RPC_PORT=8545
Expand Down
23 changes: 0 additions & 23 deletions CHEATSHEET.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,3 @@ curl "http://localhost:7700/api/subgraphs/id/BFr2mx7FgkJ36Y6pE5BiXs1KmNUmVDCnL82
docker exec -it redpanda rpk topic consume gateway_client_query_results --brokers="localhost:9092"
```

### TAP subgraph

- subgraph: http://localhost:8000/subgraphs/name/semiotic/tap

```graphql
{
escrowAccounts {
balance
sender {
id
}
receiver {
id
}
}
_meta {
block {
number
}
deployment
}
}
```
1 change: 0 additions & 1 deletion containers/core/gateway/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set -eu

cd /opt
graph_tally_verifier=$(contract_addr GraphTallyCollector.address horizon)
tap_verifier=$(contract_addr TAPVerifier tap-contracts)
dispute_manager=$(contract_addr DisputeManager.address subgraph-service)
subgraph_service=$(contract_addr SubgraphService.address subgraph-service)
echo "Waiting for network subgraph..." >&2
Expand Down
15 changes: 6 additions & 9 deletions containers/core/graph-contracts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# (see .github/actions/setup/action.yml in the contracts repo).
FROM node:24-bookworm-slim
ARG CONTRACTS_COMMIT
ARG TAP_CONTRACTS_COMMIT

# libudev-dev / libusb-1.0-0-dev: required by contracts repo's pnpm install
# (native deps of hardhat-secure-accounts / ledger toolchain). Upstream CI
Expand Down Expand Up @@ -30,14 +29,12 @@ RUN git clone https://github.com/graphprotocol/contracts && \
cd contracts && git checkout ${CONTRACTS_COMMIT} && \
pnpm install --frozen-lockfile && pnpm build

# 2. TAP contracts (separate repo, yarn-based — pin yarn here, not globally)
RUN corepack prepare yarn@1.22.22 --activate && \
git clone https://github.com/semiotic-ai/timeline-aggregation-protocol-contracts && \
cd timeline-aggregation-protocol-contracts && git checkout ${TAP_CONTRACTS_COMMIT} && \
yarn && forge build

# DataEdge (packages/data-edge in the contracts workspace) is built by the
# Phase 1 `pnpm build` above; deploy happens at runtime from /opt/contracts.
# 2. DataEdge contracts (fixed commit, for block-oracle setup)
RUN git clone https://github.com/graphprotocol/contracts contracts-data-edge && \
cd contracts-data-edge && git checkout bdc66135e7700e9a4dcd6a4beac585337fdb9c21 && \
cd packages/data-edge && pnpm install && \
sed -i "s/localhost/chain/g" hardhat.config.ts && \
pnpm build

COPY --chmod=755 ./run.sh /opt/run.sh
ENTRYPOINT ["bash", "/opt/run.sh"]
82 changes: 14 additions & 68 deletions containers/core/graph-contracts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu
. /opt/shared/lib.sh

# -- Ensure config files exist (empty JSON on first run) --
for f in horizon.json subgraph-service.json issuance.json tap-contracts.json block-oracle.json; do
for f in horizon.json subgraph-service.json issuance.json block-oracle.json; do
[ -f "/opt/config/$f" ] || echo '{}' > "/opt/config/$f"
done

Expand Down Expand Up @@ -98,79 +98,25 @@ fi
echo "==== Phase 1 complete ===="

# ============================================================
# Phase 2: TAP contracts
# Phase 2: DataEdge contract
# ============================================================
echo "==== Phase 2: TAP contracts ===="
echo "==== Phase 2: DataEdge contract ===="

# -- Idempotency check --
phase2_skip=false
escrow_address=$(jq -r '."1337".Escrow // empty' /opt/config/tap-contracts.json 2>/dev/null || true)
if [ -n "$escrow_address" ]; then
code_check=$(cast code --rpc-url="http://chain:${CHAIN_RPC_PORT}" "$escrow_address" 2>/dev/null || echo "0x")
if [ "$code_check" != "0x" ]; then
echo "TAP contracts already deployed (Escrow at $escrow_address)"
echo "SKIP: Phase 2"
phase2_skip=true
else
echo "TAP contract addresses are stale (no code at Escrow $escrow_address), redeploying..."
fi
fi

if [ "$phase2_skip" = "false" ]; then
cd /opt/timeline-aggregation-protocol-contracts

staking=$(contract_addr HorizonStaking.address horizon)
graph_token=$(contract_addr L2GraphToken.address horizon)

# Note: forge may output alloy log lines to stdout after the JSON; sed extracts only the JSON object
forge create --broadcast --json --rpc-url="http://chain:${CHAIN_RPC_PORT}" --mnemonic="${MNEMONIC}" \
src/AllocationIDTracker.sol:AllocationIDTracker \
| tee allocation_tracker.json
allocation_tracker="$(sed -n '/^{/,/^}/p' allocation_tracker.json | jq -r '.deployedTo')"

forge create --broadcast --json --rpc-url="http://chain:${CHAIN_RPC_PORT}" --mnemonic="${MNEMONIC}" \
src/TAPVerifier.sol:TAPVerifier --constructor-args 'TAP' '1' \
| tee verifier.json
verifier="$(sed -n '/^{/,/^}/p' verifier.json | jq -r '.deployedTo')"

forge create --broadcast --json --rpc-url="http://chain:${CHAIN_RPC_PORT}" --mnemonic="${MNEMONIC}" \
src/Escrow.sol:Escrow --constructor-args "${graph_token}" "${staking}" "${verifier}" "${allocation_tracker}" 10 15 \
| tee escrow.json
escrow="$(sed -n '/^{/,/^}/p' escrow.json | jq -r '.deployedTo')"

cat <<EOF > /opt/config/tap-contracts.json
{
"1337": {
"AllocationIDTracker": "$allocation_tracker",
"TAPVerifier": "$verifier",
"Escrow": "$escrow"
}
}
EOF
fi

echo "==== Phase 2 complete ===="

# ============================================================
# Phase 3: DataEdge contract
# ============================================================
echo "==== Phase 3: DataEdge contract ===="

# -- Idempotency check --
phase3_skip=false
data_edge=$(jq -r '."1337".DataEdge // empty' /opt/config/block-oracle.json 2>/dev/null || true)
if [ -n "$data_edge" ]; then
code_check=$(cast code --rpc-url="http://chain:${CHAIN_RPC_PORT}" "$data_edge" 2>/dev/null || echo "0x")
if [ "$code_check" != "0x" ]; then
echo "DataEdge contract already deployed at $data_edge"
echo "SKIP: Phase 3"
phase3_skip=true
echo "SKIP: Phase 2"
phase2_skip=true
else
echo "DataEdge address stale (no code at $data_edge), redeploying..."
fi
fi

if [ "$phase3_skip" = "false" ]; then
if [ "$phase2_skip" = "false" ]; then
cd /opt/contracts/packages/data-edge
# hardhat.config.ts hardcodes `localhost:8545` for the ganache network and
# the standard test mnemonic; patch both for the local-network stack.
Expand Down Expand Up @@ -203,15 +149,15 @@ ADDR_EOF
fi
fi

echo "==== Phase 3 complete ===="
echo "==== Phase 2 complete ===="

# ============================================================
# Phase 4: Rewards Eligibility Oracle (REO)
# Phase 3: Rewards Eligibility Oracle (REO)
# ============================================================
if [ "${REO_ENABLED:-0}" != "1" ]; then
echo "==== Phase 4: Rewards Eligibility Oracle (SKIPPED — REO_ENABLED not set) ===="
echo "==== Phase 3: Rewards Eligibility Oracle (SKIPPED — REO_ENABLED not set) ===="
else
echo "==== Phase 4: Rewards Eligibility Oracle ===="
echo "==== Phase 3: Rewards Eligibility Oracle ===="

# Ensure NetworkOperator in issuance address book (required by configure step)
TEMP_JSON=$(jq --arg op "${ACCOUNT0_ADDRESS}" \
Expand All @@ -225,20 +171,20 @@ printf '%s\n' "$TEMP_JSON" > /opt/config/issuance.json
# (OPERATOR). So we only run hardhat deploy for initial deployment; on
# re-runs where the REO proxy already exists on-chain, skip straight to
# the idempotent configuration below.
phase4_deploy_skip=false
phase3_deploy_skip=false
reo_address=$(jq -r '.["1337"].RewardsEligibilityOracle.address // empty' /opt/config/issuance.json 2>/dev/null || true)
if [ -n "$reo_address" ]; then
code_check=$(cast code --rpc-url="http://chain:${CHAIN_RPC_PORT}" "$reo_address" 2>/dev/null || echo "0x")
if [ "$code_check" != "0x" ]; then
echo "REO already deployed at $reo_address"
echo "SKIP: hardhat deploy (configuration handled below)"
phase4_deploy_skip=true
phase3_deploy_skip=true
else
echo "REO address stale (no code at $reo_address), redeploying..."
fi
fi

if [ "$phase4_deploy_skip" = "false" ]; then
if [ "$phase3_deploy_skip" = "false" ]; then
cd /opt/contracts/packages/deployment

# Clean any stale governance TX batches from partial runs
Expand Down Expand Up @@ -344,7 +290,7 @@ for ab in horizon.json subgraph-service.json; do
fi
done

echo "==== Phase 4 complete ===="
echo "==== Phase 3 complete ===="
fi # REO_ENABLED
echo "==== All contract deployments complete ===="

Expand Down
7 changes: 1 addition & 6 deletions containers/core/subgraph-deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM node:23.11-bookworm-slim
ARG NETWORK_SUBGRAPH_COMMIT
ARG TAP_SUBGRAPH_COMMIT
ARG BLOCK_ORACLE_COMMIT

RUN apt-get update \
Expand All @@ -24,11 +23,7 @@ RUN git clone https://github.com/graphprotocol/graph-network-subgraph && \
cd graph-network-subgraph && git checkout ${NETWORK_SUBGRAPH_COMMIT} && \
pnpm install && pnpm add -D ts-node

# 2. TAP subgraph
RUN git clone https://github.com/semiotic-ai/timeline-aggregation-protocol-subgraph --recursive && \
cd timeline-aggregation-protocol-subgraph && git checkout ${TAP_SUBGRAPH_COMMIT} && yarn

# 3. Block oracle subgraph
# 2. Block oracle subgraph
RUN git clone https://github.com/graphprotocol/block-oracle && \
cd block-oracle && git checkout ${BLOCK_ORACLE_COMMIT} && \
cd packages/subgraph && yarn
Expand Down
33 changes: 1 addition & 32 deletions containers/core/subgraph-deploy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,6 @@ deploy_network() {
echo "==== Network subgraph done ===="
}

deploy_tap() {
echo "==== TAP subgraph ===="
if curl -s "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/semiotic/tap" \
-H 'content-type: application/json' \
-d '{"query": "{ _meta { deployment } }" }' | grep -q "_meta"
then
echo "SKIP: TAP subgraph already deployed"
return
fi

escrow=$(contract_addr Escrow tap-contracts)

cd /opt/timeline-aggregation-protocol-subgraph
sed -i "s/127.0.0.1:5001/ipfs:${IPFS_RPC_PORT}/g" package.json
sed -i "s/127.0.0.1:8020/graph-node:${GRAPH_NODE_ADMIN_PORT}/g" package.json
yq ".dataSources[].source.address=\"${escrow}\"" -i subgraph.yaml
yq ".dataSources[].network |= \"hardhat\"" -i subgraph.yaml
yarn codegen
yarn build
yarn create-local
yarn deploy-local | tee deploy.txt
deployment_id="$(grep "Build completed: " deploy.txt | awk '{print $3}' | sed -e 's/\x1b\[[0-9;]*m//g')"
curl -s "http://graph-node:${GRAPH_NODE_ADMIN_PORT}" \
-H 'content-type: application/json' \
-d "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"subgraph_reassign\",\"params\":{\"node_id\":\"default\",\"ipfs_hash\":\"${deployment_id}\"}}"
echo "==== TAP subgraph done ===="
}

deploy_block_oracle() {
echo "==== Block-oracle subgraph ===="
if curl -s "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/block-oracle" \
Expand Down Expand Up @@ -102,18 +74,15 @@ deploy_block_oracle() {
echo "==== Block-oracle subgraph done ===="
}

# Launch all three in parallel
# Launch in parallel
deploy_network &
pid_network=$!
deploy_tap &
pid_tap=$!
deploy_block_oracle &
pid_oracle=$!

# Wait for all, fail if any fails
failed=0
wait $pid_network || { echo "FAILED: Network subgraph"; failed=1; }
wait $pid_tap || { echo "FAILED: TAP subgraph"; failed=1; }
wait $pid_oracle || { echo "FAILED: Block-oracle subgraph"; failed=1; }

if [ "$failed" -ne 0 ]; then
Expand Down
2 changes: 0 additions & 2 deletions containers/indexer/indexer-agent/dev/run-override.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fi

export INDEXER_AGENT_HORIZON_ADDRESS_BOOK=/opt/config/horizon.json
export INDEXER_AGENT_SUBGRAPH_SERVICE_ADDRESS_BOOK=/opt/config/subgraph-service.json
export INDEXER_AGENT_TAP_ADDRESS_BOOK=/opt/config/tap-contracts.json
export INDEXER_AGENT_EPOCH_SUBGRAPH_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/block-oracle"
export INDEXER_AGENT_GATEWAY_ENDPOINT="http://gateway:${GATEWAY_PORT}"
export INDEXER_AGENT_GRAPH_NODE_QUERY_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}"
Expand All @@ -46,7 +45,6 @@ export INDEXER_AGENT_POSTGRES_PORT="${POSTGRES_PORT}"
export INDEXER_AGENT_POSTGRES_USERNAME=postgres
export INDEXER_AGENT_POSTGRES_PASSWORD=
export INDEXER_AGENT_PUBLIC_INDEXER_URL="http://indexer-service:${INDEXER_SERVICE_PORT}"
export INDEXER_AGENT_TAP_SUBGRAPH_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/semiotic/tap"
export INDEXER_AGENT_MAX_PROVISION_INITIAL_SIZE=200000
export INDEXER_AGENT_CONFIRMATION_BLOCKS=1
export INDEXER_AGENT_LOG_LEVEL=trace
Expand Down
2 changes: 0 additions & 2 deletions containers/indexer/indexer-agent/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ fi

export INDEXER_AGENT_HORIZON_ADDRESS_BOOK=/opt/config/horizon.json
export INDEXER_AGENT_SUBGRAPH_SERVICE_ADDRESS_BOOK=/opt/config/subgraph-service.json
export INDEXER_AGENT_TAP_ADDRESS_BOOK=/opt/config/tap-contracts.json
export INDEXER_AGENT_EPOCH_SUBGRAPH_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/block-oracle"
export INDEXER_AGENT_GATEWAY_ENDPOINT="http://gateway:${GATEWAY_PORT}"
export INDEXER_AGENT_GRAPH_NODE_QUERY_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}"
Expand All @@ -60,7 +59,6 @@ export INDEXER_AGENT_POSTGRES_PORT="${POSTGRES_PORT}"
export INDEXER_AGENT_POSTGRES_USERNAME=postgres
export INDEXER_AGENT_POSTGRES_PASSWORD=
export INDEXER_AGENT_PUBLIC_INDEXER_URL="http://indexer-service:${INDEXER_SERVICE_PORT}"
export INDEXER_AGENT_TAP_SUBGRAPH_ENDPOINT="http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/semiotic/tap"
export INDEXER_AGENT_MAX_PROVISION_INITIAL_SIZE=200000
export INDEXER_AGENT_CONFIRMATION_BLOCKS=1
export INDEXER_AGENT_LOG_LEVEL=trace
Expand Down
5 changes: 0 additions & 5 deletions containers/indexer/indexer-service/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -eu

. /opt/shared/lib.sh

tap_verifier=$(contract_addr TAPVerifier tap-contracts)
graph_tally_verifier=$(contract_addr GraphTallyCollector.address horizon)
subgraph_service=$(contract_addr SubgraphService.address subgraph-service)

Expand All @@ -25,10 +24,6 @@ query_url = "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/graph-n
recently_closed_allocation_buffer_secs = 60
syncing_interval_secs = 30

[subgraphs.escrow]
query_url = "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/semiotic/tap"
syncing_interval_secs = 30

[blockchain]
chain_id = 1337
receipts_verifier_address_v2 = "${graph_tally_verifier}"
Expand Down
9 changes: 3 additions & 6 deletions containers/indexer/start-indexing/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ then
signal_per_dep="1000000000000000000000" # 1000 GRT per deployment
added=0

for subgraph_name in graph-network block-oracle semiotic/tap; do
for subgraph_name in graph-network block-oracle; do
dep_id="$(curl -s "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/${subgraph_name}" \
-H 'content-type: application/json' \
-d '{"query": "{ _meta { deployment } }" }' | jq -r '.data._meta.deployment')"
Expand Down Expand Up @@ -77,11 +77,9 @@ get_deployment() {

network_deployment="$(get_deployment graph-network)"
block_oracle_deployment="$(get_deployment block-oracle)"
tap_deployment="$(get_deployment semiotic/tap)"

elapsed "network_deployment=${network_deployment}"
elapsed "block_oracle_deployment=${block_oracle_deployment}"
elapsed "tap_deployment=${tap_deployment}"

# -- Publish subgraphs to GNS (required for allocations) --
subgraph_count=$(curl -s "http://graph-node:${GRAPH_NODE_GRAPHQL_PORT}/subgraphs/name/graph-network" \
Expand All @@ -92,7 +90,7 @@ if [ "${subgraph_count:-0}" -ge 3 ]; then
else
gns=$(contract_addr L2GNS.address subgraph-service)
all_dep_hexes=""
for dep_name in network tap block_oracle; do
for dep_name in network block_oracle; do
eval dep_id=\$${dep_name}_deployment
dep_hex="$(curl -s -X POST "http://ipfs:${IPFS_RPC_PORT}/api/v0/cid/format?arg=${dep_id}&b=base16" | jq -r '.Formatted')"
dep_hex="${dep_hex#f01701220}"
Expand Down Expand Up @@ -128,11 +126,10 @@ fi
graph-indexer indexer connect "http://indexer-agent:${INDEXER_MANAGEMENT_PORT}"
graph-indexer indexer --network=hardhat rules set "${network_deployment}" decisionBasis always -o json
graph-indexer indexer --network=hardhat rules set "${block_oracle_deployment}" decisionBasis always -o json
graph-indexer indexer --network=hardhat rules set "${tap_deployment}" decisionBasis always -o json

# -- Resume subgraphs that may have been paused by indexer-agent --
elapsed "Resuming subgraphs..."
for dep in "${network_deployment}" "${block_oracle_deployment}" "${tap_deployment}"; do
for dep in "${network_deployment}" "${block_oracle_deployment}"; do
curl -s -X POST "http://graph-node:${GRAPH_NODE_ADMIN_PORT}/" -H 'content-type: application/json' \
-d "{\"jsonrpc\": \"2.0\", \"method\": \"subgraph_resume\", \"params\": {\"deployment\": \"${dep}\"}, \"id\": 1}"
done
Expand Down
Loading