Merge pull request #332 from blockfrost/ci-improvement
build the flake on runner1, so its pre-built for dev
build the flake on runner1, so its pre-built for dev
Wrap the driving-table filter + ORDER BY + LIMIT/OFFSET in a CTE so
Postgres materializes the page first, then joins to tx / block /
gov_action_proposal / pool_hash only for the page we return — not
for every matching row.
Two endpoints applied (paged + unpaged variants each):
GET /governance/dreps/:drep_id/votes
Original plan: seq-scan voting_procedure (25k rows on mainnet),
hash-join to drep_hash → 130 rows for a busy DRep, 4 nested-loop
joins fire on all 130, sort + top-N 100. ~65ms warm.
New plan: filter voting_procedure to the drep's 130 rows, sort
+ limit to 100, then 3 nested-loop joins fire only on 100. ~30ms warm.
Live end-to-end: ~140ms → ~50ms (~2.9x).
GET /accounts/:stake_address/delegations
Original plan: stake_address → delegation index scan returns 1282
rows for a heavily-delegated account, 3 joins (tx + block + pool_hash)
fire on all 1282, then sort + top-N 100. ~60ms warm SQL.
New plan: filter + sort + limit delegations to 100 (via d.tx_id
ordering directly from the delegation row), then 3 joins fire on
100. ~2ms warm SQL. 27x speedup at the DB layer.
No response shape changes. Same fields, same ordering semantics, same
edge cases.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Wrap the voting_procedure filter + ORDER BY + LIMIT/OFFSET in a `paged_votes` CTE so Postgres materializes the page first (via an index scan on voting_procedure_pkey), then does the joins against tx, block, gov_action_proposal, tx (proposal), and voting_anchor only for the page we return — not for every CC vote on the chain. Live end-to-end measurements (mainnet dev backend): /committee/votes?count=100 170ms → 50ms (3.4x) /committee/votes?count=100&order=desc 190ms → 50ms (3.8x) /committee/:cc_hot/votes?count=100 150ms → 50ms (3.0x) /committee/:cc_cold/votes?count=100 145ms → 47ms (3.1x) EXPLAIN buffer reads dropped from ~12k to ~1.9k for count=100, which also reduces cold-cache tail latency. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
db-sync inserts a committee row for every NewCommittee proposal, not only enacted ones. The previous ORDER BY committee.id DESC LIMIT 1 returned the most recently proposed committee even when it had expired or been dropped, surfacing the wrong gov_action_id on /governance/committee. Fix: LEFT JOIN to gov_action_proposal and keep only rows where the proposal is enacted (or the genesis row, which has no proposal). Order by enacted_epoch DESC with id as tiebreaker. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
feat: expose deposit on account and drep endpoints
Missed the unpaged variant when fixing the paged one. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Match the openapi schema (null on `deregistered` and `updated`) and align with the stake-account registrations endpoint's convention, where `null` denotes "not the deposit-paying side of the event". Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Keep deposit only on the per-event endpoints (/registrations and /updates) where it semantically belongs. The top-level fields were redundant — same number derivable from a single registrations/updates row — and the "deposit paid at registration" framing differs from Koios's "deposit currently locked" semantics, inviting confusion. Reverts: - accounts_stake_address.sql: drop the `deposit` column and the registration_state CTE; restore the inline MAX-tx_id comparison for the `registered` field. - dreps_drep_id.sql: drop the `deposit` column. - TS query types: drop `deposit` from Account and DRepsDrepID. - Account fixtures: drop `deposit` from /accounts/:stake_address query/response fixtures (keeps it on the registrations fixtures). Bumps @blockfrost/openapi to 0.1.88-beta.2 (drops `deposit` from account_content and drep schemas). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds three endpoints for surfacing constitutional committee state and votes: - GET /governance/committee — current committee snapshot with members, quorum, members count, and source NewCommittee gov action (genesis committee returns proposal fields as null and `is_genesis: true`). - GET /governance/committee/votes — paged list of all CC votes ever cast. - GET /governance/committee/:cc_id/votes — paged list of votes filtered by CIP-129 hot (cc_hot1...) or cold (cc_cold1...) credential. Cold queries aggregate across every hot key the cold has authorized. Per-vote shape includes the voting anchor (metadata_url / metadata_hash), governance_type, block height/time, and the voter's CIP-129 hot id. Depends on a forthcoming @blockfrost/openapi release that adds the matching path + schema definitions. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Fixtures: add `deposit` to /accounts/:stake_address response/query fixtures and per-row to /accounts/:stake_address/registrations (registered → string; deregistered → null) so route unit tests cover the new field per Copilot review. - SQL: lift the `MAX(stake_registration.tx_id) > MAX(stake_deregistration.tx_id)` comparison into a `registration_state` CTE and reuse it from both the `registered` field and the deposit CASE. Eliminates a redundant pair of subqueries per request. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds a `deposit` field to: - /accounts/:stake_address - /accounts/:stake_address/registrations (per row) - /governance/dreps/:drep_id - /governance/dreps/:drep_id/updates (per row) For stake registrations, falls back to epoch_param.key_deposit at the registration's epoch when stake_registration.deposit is NULL (rows predating db-sync's deposit column). Requires @blockfrost/openapi 0.1.88-beta.0 for the matching schema. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>