From 6c916421982f3341cdde79c78536c11f5b77ce77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Thu, 13 Feb 2025 14:36:04 +0100 Subject: [PATCH 1/8] chore: change automated pillar package update commit message --- .github/workflows/update-intersect-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-intersect-package.yml b/.github/workflows/update-intersect-package.yml index e2fb1d680..f93759b13 100644 --- a/.github/workflows/update-intersect-package.yml +++ b/.github/workflows/update-intersect-package.yml @@ -58,6 +58,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} branch: "chore/${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}" title: "Update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}" + commit-message: "chore: update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}" body: | This PR updates `${{ github.event.inputs.package_name }}` to version `${{ github.event.inputs.new_version }}`. From 457a42b05b3abc43b2216c555a4f5531d3206410 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 14 Feb 2025 10:30:30 +0545 Subject: [PATCH 2/8] fix: update commit status API to use workflow run head SHA --- .github/scripts/set_commit_status.sh | 4 ++-- .github/workflows/test_backend.yml | 2 +- .github/workflows/test_integration_playwright.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/set_commit_status.sh b/.github/scripts/set_commit_status.sh index 01a822304..988529d9b 100644 --- a/.github/scripts/set_commit_status.sh +++ b/.github/scripts/set_commit_status.sh @@ -1,7 +1,7 @@ #!/bin/bash # Ensure required environment variables are set -if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$GITHUB_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then +if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then echo "Missing required environment variables!" exit 1 fi @@ -69,7 +69,7 @@ fi # Send commit status update to GitHub curl -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA} \ -d "{\"state\": \"${TEST_STATUS}\", \"context\": \"${CONTEXT}\", \"description\": \"${DESCRIPTION}\", \"target_url\": \"${TARGET_URL}\"}" echo "Commit status updated successfully!" diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 59488d061..609fda94f 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -53,7 +53,7 @@ jobs: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT curl -X POST -H "Authorization: Bearer ${{ github.token }}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ + https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ -d "{\"state\": \"pending\", \"context\": \"Backend Tests : ${{env.BASE_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index b3c1591db..4d91eb5ca 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -54,7 +54,7 @@ jobs: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT curl -X POST -H "Authorization: Bearer ${{ github.token }}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ + https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ -d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" - uses: actions/setup-node@v4 From 4dad94cdfe9cb113bd10add0cb19c525f3f8c71d Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 14 Feb 2025 10:48:35 +0545 Subject: [PATCH 3/8] fix: update checkout step to use workflow run head SHA in test --- .github/workflows/test_backend.yml | 2 ++ .github/workflows/test_integration_playwright.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 609fda94f..8148c4eeb 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -46,6 +46,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Set pending commit status id: set-pending-status diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 4d91eb5ca..2b09d1aaa 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -48,6 +48,8 @@ jobs: working-directory: tests/govtool-frontend/playwright steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Set pending commit status id: set-pending-status run: | From 8b0d832b96b8e5d12c7ddaefe0c7038d79343f04 Mon Sep 17 00:00:00 2001 From: Niraj Date: Fri, 14 Feb 2025 11:56:57 +0545 Subject: [PATCH 4/8] fix: commit sha for manual trigger --- .github/scripts/set_commit_status.sh | 4 ++-- .github/workflows/test_backend.yml | 5 +++-- .github/workflows/test_integration_playwright.yml | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/scripts/set_commit_status.sh b/.github/scripts/set_commit_status.sh index 988529d9b..73b460812 100644 --- a/.github/scripts/set_commit_status.sh +++ b/.github/scripts/set_commit_status.sh @@ -1,7 +1,7 @@ #!/bin/bash # Ensure required environment variables are set -if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then +if [ -z "$GITHUB_REPOSITORY" ] || [ -z "$COMMIT_SHA" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_RUN_ID" ]; then echo "Missing required environment variables!" exit 1 fi @@ -69,7 +69,7 @@ fi # Send commit status update to GitHub curl -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA} \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${COMMIT_SHA} \ -d "{\"state\": \"${TEST_STATUS}\", \"context\": \"${CONTEXT}\", \"description\": \"${DESCRIPTION}\", \"target_url\": \"${TARGET_URL}\"}" echo "Commit status updated successfully!" diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 8148c4eeb..28c7b1599 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -47,7 +47,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.workflow_run.head_sha }} + ref: ${{ env.COMMIT_SHA }} - name: Set pending commit status id: set-pending-status @@ -55,7 +55,7 @@ jobs: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT curl -X POST -H "Authorization: Bearer ${{ github.token }}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ + https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \ -d "{\"state\": \"pending\", \"context\": \"Backend Tests : ${{env.BASE_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" @@ -186,3 +186,4 @@ env: BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }} REPORT_NAME: govtool-backend GH_PAGES: ${{vars.GH_PAGES}} + COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} diff --git a/.github/workflows/test_integration_playwright.yml b/.github/workflows/test_integration_playwright.yml index 2b09d1aaa..cf5e0ed63 100644 --- a/.github/workflows/test_integration_playwright.yml +++ b/.github/workflows/test_integration_playwright.yml @@ -49,14 +49,14 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.workflow_run.head_sha }} + ref: ${{ env.COMMIT_SHA }} - name: Set pending commit status id: set-pending-status run: | echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT curl -X POST -H "Authorization: Bearer ${{ github.token }}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }} \ + https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \ -d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" - uses: actions/setup-node@v4 @@ -225,3 +225,4 @@ env: HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }} REPORT_NAME: govtool-frontend GH_PAGES: ${{vars.GH_PAGES}} + COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} From 4f87b8766aba737ed3f0986f3482a7705cb0f3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 11 Feb 2025 10:10:51 +0100 Subject: [PATCH 5/8] feat(#1188): add button to submit a governance action --- CHANGELOG.md | 1 + .../organisms/DashboardGovernanceActions.tsx | 82 ++++++++++++------- govtool/frontend/src/i18n/locales/en.json | 1 + .../frontend/src/pages/GovernanceActions.tsx | 3 +- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f802f639f..8be337c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ changes. - Add CC votes percentages, not voted and Ratification threshold - Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258) - Add workflow to automatically update any of the @intersect.mbo package [Issue 2968](https://github.com/IntersectMBO/govtool/issues/2968) +- Add Propose Governance Action button in governance actions dashboard [Issue 1188](https://github.com/IntersectMBO/govtool/issues/1188) ### Fixed diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx index 3bcf8bb90..2efc90aa6 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx @@ -1,12 +1,14 @@ -import { useState, useEffect } from "react"; +import { useState, useEffect, useCallback } from "react"; import { Box, CircularProgress, Tab, Tabs, styled } from "@mui/material"; -import { useLocation } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; import { GOVERNANCE_ACTIONS_FILTERS, GOVERNANCE_ACTIONS_SORTING, + PATHS, + PDF_PATHS, } from "@consts"; -import { useCardano, useDataActionsBar } from "@context"; +import { useCardano, useDataActionsBar, useFeatureFlag } from "@context"; import { useGetProposalsQuery, useGetVoterInfo, @@ -18,6 +20,7 @@ import { GovernanceActionsToVote, DashboardGovernanceActionsVotedOn, } from "@organisms"; +import { Button } from "@atoms"; type TabPanelProps = { children?: React.ReactNode; @@ -74,6 +77,8 @@ export const DashboardGovernanceActions = () => { const { isMobile } = useScreenDimension(); const { t } = useTranslation(); const { isEnableLoading } = useCardano(); + const { isProposalDiscussionForumEnabled } = useFeatureFlag(); + const navigate = useNavigate(); const queryFilters = chosenFilters.length > 0 ? chosenFilters : defaultCategories; @@ -94,6 +99,14 @@ export const DashboardGovernanceActions = () => { setContent(newValue); }; + const onClickPropose = useCallback(() => { + navigate( + isProposalDiscussionForumEnabled + ? PDF_PATHS.proposalDiscussionPropose + : PATHS.createGovernanceAction, + ); + }, [isProposalDiscussionForumEnabled]); + useEffect(() => { window.history.replaceState({}, document.title); }, []); @@ -126,36 +139,49 @@ export const DashboardGovernanceActions = () => { ) : ( <> {(voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter) && ( - - + - + + + + + )} + { filtersTitle={t("govActions.filterTitle")} sortOptions={GOVERNANCE_ACTIONS_SORTING} /> - {!proposals || isProposalsLoading ? ( Date: Fri, 14 Feb 2025 10:17:19 +0100 Subject: [PATCH 6/8] fix: lint error on unused import --- govtool/frontend/src/pages/GovernanceActions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govtool/frontend/src/pages/GovernanceActions.tsx b/govtool/frontend/src/pages/GovernanceActions.tsx index 0fc687004..a461c1a6a 100644 --- a/govtool/frontend/src/pages/GovernanceActions.tsx +++ b/govtool/frontend/src/pages/GovernanceActions.tsx @@ -2,7 +2,7 @@ import { useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { Box, CircularProgress, Divider } from "@mui/material"; -import { Background, Button, ScrollToManage, Typography } from "@atoms"; +import { Background, ScrollToManage, Typography } from "@atoms"; import { GOVERNANCE_ACTIONS_FILTERS, GOVERNANCE_ACTIONS_SORTING, From 83247a221129a6f4616483aa1172db18e6d5d6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 14 Feb 2025 16:40:37 +0100 Subject: [PATCH 7/8] fix: unhandled exception when member hash is not correct --- govtool/backend/sql/list-proposals.sql | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/govtool/backend/sql/list-proposals.sql b/govtool/backend/sql/list-proposals.sql index cedc4e86d..2c0de7f10 100644 --- a/govtool/backend/sql/list-proposals.sql +++ b/govtool/backend/sql/list-proposals.sql @@ -85,10 +85,13 @@ EnrichedCurrentMembers AS ( ) AS enriched_members FROM ProcessedCurrentMembers pcm - LEFT JOIN - json_array_elements(pcm.current_members) AS member ON true - LEFT JOIN - CommitteeData cm ON cm.hash = encode(decode(member->>'hash', 'hex'), 'hex') + LEFT JOIN json_array_elements(pcm.current_members) AS member ON true + LEFT JOIN CommitteeData cm + ON (CASE + WHEN (member->>'hash') ~ '^[0-9a-fA-F]+$' + THEN encode(decode(member->>'hash', 'hex'), 'hex') + ELSE NULL + END) = cm.hash GROUP BY pcm.id ), @@ -199,7 +202,13 @@ SELECT 'tag', pd.tag, 'members', em.enriched_members, 'membersToBeRemoved', mtr.members_to_be_removed, - 'threshold', pd.threshold::float + 'threshold', + CASE + WHEN (pd.threshold->>'numerator') IS NOT NULL + AND (pd.threshold->>'denominator') IS NOT NULL + THEN (pd.threshold->>'numerator')::float / (pd.threshold->>'denominator')::float + ELSE NULL + END ) FROM ParsedDescription pd From 26324eae1745d0bff24a7853ea612bd7cc9f324e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 14 Feb 2025 21:58:58 +0100 Subject: [PATCH 8/8] chore: get rid of window functions in drep list query --- govtool/backend/sql/list-dreps.sql | 69 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/govtool/backend/sql/list-dreps.sql b/govtool/backend/sql/list-dreps.sql index 0a6d92d1e..2c3b87aa5 100644 --- a/govtool/backend/sql/list-dreps.sql +++ b/govtool/backend/sql/list-dreps.sql @@ -1,10 +1,7 @@ WITH DRepDistr AS ( - SELECT - drep_distr.*, - ROW_NUMBER() OVER (PARTITION BY drep_hash.id ORDER BY drep_distr.epoch_no DESC) AS rn - FROM - drep_distr - JOIN drep_hash ON drep_hash.id = drep_distr.hash_id + SELECT DISTINCT ON (drep_distr.hash_id) drep_distr.* + FROM drep_distr + ORDER BY drep_distr.hash_id, drep_distr.epoch_no DESC ), DRepActivity AS ( SELECT @@ -19,11 +16,12 @@ DRepActivity AS ( LIMIT 1 ), LatestVotingProcedure AS ( - SELECT - vp.*, - ROW_NUMBER() OVER (PARTITION BY drep_voter ORDER BY tx_id DESC) AS rn + SELECT DISTINCT ON (vp.drep_voter) + vp.* FROM voting_procedure vp + ORDER BY + vp.drep_voter, vp.tx_id DESC ), LatestVoteEpoch AS ( SELECT @@ -33,20 +31,19 @@ LatestVoteEpoch AS ( LatestVotingProcedure lvp JOIN tx ON tx.id = lvp.tx_id JOIN block ON block.id = tx.block_id - WHERE - lvp.rn = 1 ), RankedDRepRegistration AS ( - SELECT + SELECT DISTINCT ON (dr.drep_hash_id) dr.id, dr.drep_hash_id, dr.deposit, dr.voting_anchor_id, - ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn, encode(tx.hash, 'hex') AS tx_hash - FROM + FROM drep_registration dr JOIN tx ON tx.id = dr.tx_id + ORDER BY + dr.drep_hash_id, dr.tx_id DESC ), FetchError AS ( SELECT @@ -132,29 +129,31 @@ DRepData AS ( off_chain_vote_drep_data.image_hash FROM drep_hash dh - JOIN RankedDRepRegistration ON RankedDRepRegistration.drep_hash_id = dh.id AND RankedDRepRegistration.rn = 1 + JOIN RankedDRepRegistration ON RankedDRepRegistration.drep_hash_id = dh.id JOIN ( - SELECT + SELECT DISTINCT ON (dr.drep_hash_id) dr.id, dr.drep_hash_id, - dr.deposit, - ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn + dr.deposit FROM drep_registration dr WHERE dr.deposit IS NOT NULL - ) AS dr_deposit ON dr_deposit.drep_hash_id = dh.id AND dr_deposit.rn = 1 + ORDER BY + dr.drep_hash_id, dr.tx_id DESC + ) AS dr_deposit ON dr_deposit.drep_hash_id = dh.id LEFT JOIN ( - SELECT + SELECT DISTINCT ON (dr.drep_hash_id) dr.id, dr.drep_hash_id, - dr.deposit, - ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn + dr.deposit FROM drep_registration dr - ) AS latestDeposit ON latestDeposit.drep_hash_id = dh.id AND latestDeposit.rn = 1 + ORDER BY + dr.drep_hash_id, dr.tx_id DESC + ) AS latestDeposit ON latestDeposit.drep_hash_id = dh.id LEFT JOIN LatestExistingVotingAnchor leva ON leva.drep_hash_id = dh.id - LEFT JOIN DRepDistr ON DRepDistr.hash_id = dh.id AND DRepDistr.rn = 1 + LEFT JOIN DRepDistr ON DRepDistr.hash_id = dh.id LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id @@ -163,26 +162,28 @@ DRepData AS ( LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id LEFT JOIN ( - SELECT + SELECT DISTINCT ON (dr.drep_hash_id) block.epoch_no, block.time, - dr.drep_hash_id, - ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn + dr.drep_hash_id FROM - drep_registration dr + drep_registration dr JOIN tx ON tx.id = dr.tx_id JOIN block ON block.id = tx.block_id WHERE COALESCE(dr.deposit, 0) >= 0 - ) AS newestRegister ON newestRegister.drep_hash_id = dh.id AND newestRegister.rn = 1 - LEFT JOIN ( - SELECT + ORDER BY + dr.drep_hash_id, dr.tx_id DESC + ) AS newestRegister ON newestRegister.drep_hash_id = dh.id + LEFT JOIN ( + SELECT DISTINCT ON (dr.drep_hash_id) dr.tx_id, - dr.drep_hash_id, - ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id ASC) AS rn + dr.drep_hash_id FROM drep_registration dr - ) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id AND dr_first_register.rn = 1 + ORDER BY + dr.drep_hash_id, dr.tx_id ASC + ) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id LEFT JOIN LatestVoteEpoch lve ON lve.drep_id = dh.id