From db2b52c9527971b966690208c536b3fc408e8d98 Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Thu, 1 Jan 2026 16:21:07 -0500 Subject: [PATCH 1/4] Add missing index for voter filtering in witness votes history The get_witness_votes_history endpoint was timing out when filtering by voter-name because there was no index on voter_id. The existing index only covered (witness_id, source_op_block). This adds an index on (witness_id, voter_id) to enable efficient lookups when the voter-name filter is used. --- database/indexes/hafbe_app_indexes.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/database/indexes/hafbe_app_indexes.sql b/database/indexes/hafbe_app_indexes.sql index 6fa5ab09..94ee482b 100644 --- a/database/indexes/hafbe_app_indexes.sql +++ b/database/indexes/hafbe_app_indexes.sql @@ -15,6 +15,9 @@ BEGIN --Can only vote once every 3 seconds, so sorting by block_num is sufficient CREATE INDEX IF NOT EXISTS witness_votes_history_witness_id_source_op ON hafbe_app.witness_votes_history USING btree (witness_id, hafd.operation_id_to_block_num( source_op )); + -- Index for efficient voter filtering in get_witness_votes_history endpoint + CREATE INDEX IF NOT EXISTS witness_votes_history_witness_voter ON hafbe_app.witness_votes_history USING btree (witness_id, voter_id); + CREATE INDEX IF NOT EXISTS account_proxies_history_account_id_source_op ON hafbe_app.account_proxies_history USING btree (account_id, source_op); CREATE INDEX IF NOT EXISTS account_proxies_history_account_id ON hafbe_app.account_proxies_history USING btree (account_id); CREATE INDEX IF NOT EXISTS current_account_proxies_proxy_id ON hafbe_app.current_account_proxies USING btree (proxy_id); -- GitLab From 77f1734ab402492bd86fd7a91318d5335f7a77b8 Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Fri, 2 Jan 2026 23:11:35 -0500 Subject: [PATCH 2/4] Set SHARED_BLOCK_LOG_DIR to use local block_log on builders --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fcef3188..dc24392c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -495,6 +495,8 @@ sync: --ansi never # Avoid nested submodule issues GIT_SUBMODULE_STRATEGY: none + # Use local block_log on each builder (faster than NFS) + SHARED_BLOCK_LOG_DIR: /blockchain/block_log_5m timeout: 1 hours before_script: - | -- GitLab From 3f52a033919fbc5a566280da2809e75ffdf5352a Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Fri, 2 Jan 2026 23:47:47 -0500 Subject: [PATCH 3/4] Update index sentinel to trigger creation of new voter filter index When restoring from older caches, isIndexesCreated() now returns false if the new witness_votes_history_witness_voter index doesn't exist, ensuring create_hafbe_indexes() runs and creates all indexes. --- database/hafbe_app_helpers.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/hafbe_app_helpers.sql b/database/hafbe_app_helpers.sql index 9771ecfd..a4aacb14 100644 --- a/database/hafbe_app_helpers.sql +++ b/database/hafbe_app_helpers.sql @@ -44,7 +44,7 @@ BEGIN RETURN EXISTS( SELECT true FROM pg_index WHERE indexrelid = ( - SELECT oid FROM pg_class WHERE relname = 'account_proxies_history_account_id' + SELECT oid FROM pg_class WHERE relname = 'witness_votes_history_witness_voter' ) ); END -- GitLab From cd7e846d51e2d310adeb223af9dd55c03ca39b8b Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Sat, 3 Jan 2026 00:12:26 -0500 Subject: [PATCH 4/4] Remove skip rules from prepare_haf_image/data jobs These jobs should always run (passing quickly if image/data exists) rather than being skipped, to ensure HAF image is always available for downstream jobs like sync. --- .gitlab-ci.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc24392c..c849a2a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -264,9 +264,7 @@ validate_haf_commit: prepare_haf_image: stage: build - extends: - - .prepare_haf_image - - .skip_on_docs_only_or_quick_test + extends: .prepare_haf_image needs: - job: detect_changes optional: true # Not needed on protected branches @@ -293,15 +291,10 @@ prepare_haf_image: - public-runner-docker prepare_haf_data: - extends: - - .prepare_haf_data_5m - - .skip_on_docs_only_or_quick_test + extends: .prepare_haf_data_5m needs: - - job: detect_changes - optional: true - job: prepare_haf_image artifacts: true - optional: true # Not needed if build was skipped stage: build timeout: 80m variables: -- GitLab