agentleFS
genlayerlabsgenlayerlabs/genlayer-studio/.claude/skills/studio-db/SKILL.md

studio-db

Skill180 starsChanged 8 months agoMITView on GitHub

Query Studio deployment PostgreSQL databases for transaction debugging and analytics

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    CAUTION: Before any UPDATE/DELETE:

    line 136
  2. Distinctive:

    Ask user for explicit confirmation

    line 138
  3. Distinctive:

    Prefer dev/stg for testing

    line 139

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Studio Database Debugging

Query and debug the genlayer_state database for transaction issues.

Connection

For cluster access setup and connection workflow, see: devexp-apps-workload/.claude/skills/studio-db/SKILL.md

Quick connect (after setup):

export PATH="/opt/homebrew/share/google-cloud-sdk/bin:/opt/homebrew/bin:$PATH"
DBHOST=$(kubectl get secret database-config -n <namespace> -o jsonpath='{.data.DBHOST}' | base64 -d)
DBPASSWORD=$(kubectl get secret database-password -n <namespace> -o jsonpath='{.data.DBPASSWORD}' | base64 -d)

echo "<SQL>" | kubectl run pg-query --rm -i --image=postgres:16 --restart=Never \
  --namespace=<namespace> --env="PGPASSWORD=$DBPASSWORD" -- \
  psql -h "$DBHOST" -p 5432 -U postgres -d genlayer_state -t

Transaction Table Schema

Primary table for debugging (transactions):

ColumnTypeDescription
hashVARCHAR(66)Primary key, tx identifier
statusENUMTransaction lifecycle status
from_addressVARCHARSender address
to_addressVARCHARRecipient/contract address
nonceINTEGERTx sequence number
valueINTEGERTransaction value
typeINTEGERTx type (0-3)
created_atTIMESTAMPWhen tx was created
input_dataJSONBContract call input
dataJSONBTransaction data payload
consensus_dataJSONBFinal consensus results
consensus_historyJSONBFull voting history
contract_snapshotJSONBContract state at execution
appealedBOOLEANWas tx appealed
appeal_failedINTEGERAppeal failure count
appeal_undeterminedBOOLEANAppeal resulted in undetermined
appeal_leader_timeoutBOOLEANLeader timeout during appeal
appeal_validators_timeoutBOOLEANValidators timeout during appeal
leader_timeout_validatorsJSONBValidators that timed out
worker_idVARCHARWhich worker processed tx
triggered_by_hashVARCHAR(66)Parent tx hash (for tx chains)
blocked_atTIMESTAMPWhen/if tx got blocked

Transaction Statuses

PENDING → ACTIVATED → PROPOSING → COMMITTING → REVEALING → ACCEPTED → FINALIZED
                                                        ↘ UNDETERMINED
                                                        ↘ LEADER_TIMEOUT
                                                        ↘ VALIDATORS_TIMEOUT
                                                        ↘ CANCELED

Other Tables

  • current_state: Global chain state (id, data JSONB, balance)
  • validators: Validator configs (id, address, stake, provider, model, plugin)
  • llm_providers: LLM provider configurations
  • snapshot: Compressed state snapshots (snapshot_id, state_data, transaction_data)

Common Debugging Queries

Find transaction by hash

SELECT hash, status, from_address, to_address, created_at,
       consensus_data, worker_id
FROM transactions WHERE hash = '0x...';

List stuck/problematic transactions

SELECT hash, status, created_at, worker_id
FROM transactions
WHERE status IN ('UNDETERMINED', 'LEADER_TIMEOUT', 'VALIDATORS_TIMEOUT')
ORDER BY created_at DESC LIMIT 20;

Transaction status distribution

SELECT status, COUNT(*) as count
FROM transactions
GROUP BY status ORDER BY count DESC;

Recent transactions

SELECT hash, status, from_address, created_at
FROM transactions ORDER BY created_at DESC LIMIT 10;

Transactions with appeals

SELECT hash, status, appealed, appeal_undetermined, appeal_failed,
       appeal_leader_timeout, appeal_validators_timeout
FROM transactions WHERE appealed = true
ORDER BY created_at DESC LIMIT 20;

Find triggered transactions (tx chains)

SELECT t1.hash as parent, t2.hash as child, t2.status
FROM transactions t1
JOIN transactions t2 ON t2.triggered_by_hash = t1.hash
WHERE t1.hash = '0x...';

Transactions by worker

SELECT worker_id, status, COUNT(*)
FROM transactions
WHERE created_at > NOW() - INTERVAL '24 hours'
GROUP BY worker_id, status
ORDER BY worker_id, count DESC;

Check consensus history for a tx

SELECT hash, status,
       jsonb_pretty(consensus_history) as history
FROM transactions WHERE hash = '0x...';

Write Operations

CAUTION: Before any UPDATE/DELETE:

  1. First SELECT to verify affected rows
  2. Ask user for explicit confirmation
  3. Prefer dev/stg for testing

Reset stuck transaction

-- Verify first
SELECT hash, status FROM transactions
WHERE hash = '0x...' AND status = 'UNDETERMINED';

-- Then update (after confirmation)
UPDATE transactions SET status = 'PENDING' WHERE hash = '0x...';

Full Schema

Models: backend/database_handler/models.py Migrations: backend/database_handler/migration/versions/ Tx processor: backend/database_handler/transactions_processor.py

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.