Skip to content

Commit a3f6c73

Browse files
authored
Merge pull request #2420 from IntersectMBO/develop
GovTool - v1.0.28
2 parents 03e31e3 + 978fafd commit a3f6c73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+6268
-1020
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@ changes.
2626

2727
-
2828

29+
## [v1.0.28](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.28) 2024-11-26
30+
31+
### Added
32+
33+
- Add more useful metrics to the backend GET /network/metrics endpoint [Issue 2010](https://github.com/IntersectMBO/govtool/issues/2010)
34+
35+
### Fixed
36+
37+
- Fix ada holder voting power calculation
38+
- Fix wrong statuses on past DRep info
39+
- Fix listing voted-on governance actions [Issue 2379](https://github.com/IntersectMBO/govtool/issues/2379)
40+
- Fix wronly displayed markdown on slider card [Issue 2263](https://github.com/IntersectMBO/govtool/issues/2316)
41+
- fix ada quantities format to avoid thousands when the total is 0 [Issue 2372](https://github.com/IntersectMBO/govtool/issues/2382)
42+
- fix inconsistent display of delegated DRep card during delegation [Issue 2332](https://github.com/IntersectMBO/govtool/issues/2332)
43+
44+
### Changed
45+
46+
- Bump CSL version to 13.1.0 [Issue 2169](https://github.com/IntersectMBO/govtool/issues/2169)
47+
- Display supporting links below labels than in same row [Issue 2391](https://github.com/IntersectMBO/govtool/issues/2391)
48+
- change link to support page [Issue 2292](https://github.com/IntersectMBO/govtool/issues/2292)
49+
- Bump @intersect.mbo/pdf-ui to v0.5.0
50+
51+
### Removed
52+
53+
-
54+
2955
## [v1.0.27](https://github.com/IntersectMBO/govtool/releases/tag/v1.0.27) 2024-11-19
3056

3157
### Added

govtool/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
44
WORKDIR /src
55
COPY . .
66
RUN cabal build
7-
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.27/x/vva-be/build/vva-be/vva-be /usr/local/bin
7+
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.28/x/vva-be/build/vva-be/vva-be /usr/local/bin

govtool/backend/Dockerfile.qovery

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
44
WORKDIR /src
55
COPY . .
66
RUN cabal build
7-
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.27/x/vva-be/build/vva-be/vva-be /usr/local/bin
7+
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-1.0.28/x/vva-be/build/vva-be/vva-be /usr/local/bin
88

99
# Expose the necessary port
1010
EXPOSE 9876

govtool/backend/sql/get-drep-info.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ WasRegisteredAsDRep AS (
8787
CROSS JOIN DRepId
8888
WHERE
8989
drep_hash.raw = DRepId.raw
90+
AND drep_registration.deposit >= 0
9091
AND drep_registration.voting_anchor_id IS NOT NULL)) AS value
9192
),
9293
WasRegisteredAsSoleVoter AS (
@@ -100,6 +101,7 @@ WasRegisteredAsSoleVoter AS (
100101
CROSS JOIN DRepId
101102
WHERE
102103
drep_hash.raw = DRepId.raw
104+
AND drep_registration.deposit >= 0
103105
AND drep_registration.voting_anchor_id IS NULL)) AS value
104106
),
105107
CurrentMetadata AS (

govtool/backend/sql/get-network-metrics.sql

Lines changed: 144 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
WITH current_epoch AS (
1+
WITH DRepActivity AS (
2+
SELECT
3+
drep_activity AS drep_activity,
4+
epoch_no AS epoch_no
5+
FROM
6+
epoch_param
7+
WHERE
8+
epoch_no IS NOT NULL
9+
ORDER BY
10+
epoch_no DESC
11+
LIMIT 1
12+
),
13+
active_drep_boundary_epoch AS (
14+
SELECT
15+
epoch_no - drep_activity AS epoch_no
16+
FROM
17+
DRepActivity
18+
),
19+
RankedDRep AS (
20+
SELECT
21+
dh.raw AS drep_hash_raw,
22+
b.epoch_no,
23+
dr.deposit,
24+
dr.voting_anchor_id,
25+
ROW_NUMBER() OVER (PARTITION BY dh.raw ORDER BY dr.tx_id DESC) AS rank
26+
FROM
27+
drep_hash dh
28+
JOIN
29+
drep_registration dr ON dh.id = dr.drep_hash_id
30+
JOIN
31+
tx t ON dr.tx_id = t.id
32+
JOIN
33+
block b ON t.block_id = b.id
34+
WHERE
35+
dr.deposit >= 0
36+
GROUP BY
37+
dh.raw,
38+
b.epoch_no,
39+
dr.voting_anchor_id,
40+
dr.deposit,
41+
dr.tx_id
42+
),
43+
current_epoch AS (
244
SELECT
345
Max(NO) AS no
446
FROM
@@ -36,11 +78,74 @@ total_drep_votes AS (
3678
WHERE
3779
voter_role = 'DRep'
3880
),
81+
total_stake_controlled_by_dreps AS (
82+
SELECT
83+
SUM(dd.amount)::bigint AS total
84+
FROM
85+
drep_distr dd
86+
),
87+
total_registered_direct_voters AS (
88+
SELECT
89+
COUNT(DISTINCT dh.raw) AS unique_direct_voters
90+
FROM
91+
drep_registration dr
92+
JOIN
93+
drep_hash dh
94+
ON
95+
dr.drep_hash_id = dh.id
96+
LEFT JOIN
97+
voting_anchor va
98+
ON
99+
dr.voting_anchor_id = va.id
100+
WHERE
101+
dr.deposit > 0
102+
AND va.url IS NULL
103+
),
39104
total_registered_dreps AS (
105+
SELECT
106+
count(DISTINCT dh.raw) AS unique_registrations
107+
FROM
108+
drep_registration dr
109+
JOIN
110+
drep_hash dh
111+
ON
112+
dr.drep_hash_id = dh.id
113+
WHERE
114+
dr.deposit > 0
115+
),
116+
total_active_dreps AS (
40117
SELECT
41-
count(*) AS count
118+
count(DISTINCT drep_hash_raw) AS unique_active_drep_registrations
119+
FROM
120+
RankedDRep
121+
WHERE
122+
epoch_no >= (SELECT epoch_no FROM active_drep_boundary_epoch)
123+
AND rank = 1
124+
),
125+
total_inactive_dreps AS (
126+
SELECT
127+
total_registered_dreps.unique_registrations - total_active_dreps.unique_active_drep_registrations AS total_inactive_dreps
42128
FROM
43-
drep_hash
129+
total_registered_dreps
130+
CROSS JOIN
131+
total_active_dreps
132+
),
133+
total_active_cip119_compliant_dreps AS (
134+
SELECT
135+
count(DISTINCT drep_hash_raw) AS unique_active_cip119_compliant_drep_registrations
136+
FROM
137+
RankedDRep
138+
JOIN
139+
voting_anchor va on va.id = RankedDRep.voting_anchor_id
140+
JOIN off_chain_vote_data ocvd on ocvd.voting_anchor_id = va.id
141+
JOIN off_chain_vote_drep_data ocvdd on ocvdd.off_chain_vote_data_id = ocvd.id
142+
WHERE
143+
-- given_name is the only compulsory field in CIP-119
144+
ocvdd.given_name IS NOT NULL
145+
AND
146+
epoch_no >= (SELECT epoch_no FROM active_drep_boundary_epoch)
147+
AND
148+
rank = 1
44149
),
45150
always_abstain_voting_power AS (
46151
SELECT
@@ -63,15 +168,20 @@ always_no_confidence_voting_power AS (
63168
drep_hash.view = 'drep_always_no_confidence' ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
64169
)
65170
SELECT
66-
current_epoch.no,
171+
current_epoch.no as epoch_no,
67172
current_block.block_no,
68-
unique_delegators.count,
69-
total_delegations.count,
70-
total_gov_action_proposals.count,
71-
total_drep_votes.count,
72-
total_registered_dreps.count,
73-
always_abstain_voting_power.amount,
74-
always_no_confidence_voting_power.amount,
173+
unique_delegators.count as unique_delegators,
174+
total_delegations.count as total_delegations,
175+
total_gov_action_proposals.count as total_gov_action_proposals,
176+
total_drep_votes.count as total_drep_votes,
177+
total_registered_dreps.unique_registrations as total_registered_dreps,
178+
total_stake_controlled_by_dreps.total as total_stake_controlled_by_dreps,
179+
total_active_dreps.unique_active_drep_registrations as total_active_dreps,
180+
total_inactive_dreps.total_inactive_dreps as total_inactive_dreps,
181+
total_active_cip119_compliant_dreps.unique_active_cip119_compliant_drep_registrations as total_active_cip119_compliant_dreps,
182+
total_registered_direct_voters.unique_direct_voters as total_registered_direct_voters,
183+
always_abstain_voting_power.amount as always_abstain_voting_power,
184+
always_no_confidence_voting_power.amount as always_no_confidence_voting_power,
75185
network_name
76186
FROM
77187
current_epoch
@@ -81,6 +191,28 @@ FROM
81191
CROSS JOIN total_gov_action_proposals
82192
CROSS JOIN total_drep_votes
83193
CROSS JOIN total_registered_dreps
194+
CROSS JOIN total_stake_controlled_by_dreps
195+
CROSS JOIN total_active_dreps
196+
CROSS JOIN total_inactive_dreps
197+
CROSS JOIN total_active_cip119_compliant_dreps
198+
CROSS JOIN total_registered_direct_voters
84199
CROSS JOIN always_abstain_voting_power
85200
CROSS JOIN always_no_confidence_voting_power
86-
CROSS JOIN meta;
201+
CROSS JOIN meta
202+
GROUP BY
203+
current_epoch.no,
204+
current_block.block_no,
205+
unique_delegators.count,
206+
total_delegations.count,
207+
total_gov_action_proposals.count,
208+
total_drep_votes.count,
209+
total_registered_dreps.unique_registrations,
210+
total_stake_controlled_by_dreps.total,
211+
total_active_dreps.unique_active_drep_registrations,
212+
total_inactive_dreps.total_inactive_dreps,
213+
total_active_cip119_compliant_dreps.unique_active_cip119_compliant_drep_registrations,
214+
total_registered_direct_voters.unique_direct_voters,
215+
always_abstain_voting_power.amount,
216+
always_no_confidence_voting_power.amount,
217+
network_name;
218+
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
SELECT COALESCE(SUM(utxo_view.value::numeric), 0) + COALESCE(reward_sum.total_reward, 0) AS total_value,
1+
SELECT COALESCE(SUM(utxo_view.value::numeric), 0),
22
encode(stake_address.hash_raw, 'hex')
33
FROM stake_address
44
JOIN utxo_view ON utxo_view.stake_address_id = stake_address.id
5-
LEFT JOIN (
6-
SELECT addr_id, SUM(reward_rest.amount) AS total_reward
7-
FROM reward_rest
8-
GROUP BY addr_id
9-
) AS reward_sum ON reward_sum.addr_id = stake_address.id
105
WHERE stake_address.hash_raw = decode(?, 'hex')
11-
GROUP BY stake_address.hash_raw, reward_sum.total_reward;
6+
GROUP BY stake_address.hash_raw;

govtool/backend/src/VVA/API.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ getNetworkMetrics = do
437437
, getNetworkMetricsResponseTotalGovernanceActions = networkMetricsTotalGovernanceActions
438438
, getNetworkMetricsResponseTotalDRepVotes = networkMetricsTotalDRepVotes
439439
, getNetworkMetricsResponseTotalRegisteredDReps = networkMetricsTotalRegisteredDReps
440+
, getNetworkMetricsResponseTotalStakeControlledByDReps = networkMetricsTotalStakeControlledByDReps
441+
, getNetworkMetricsResponseTotalActiveDReps = networkMetricsTotalActiveDReps
442+
, getNetworkMetricsResponseTotalInactiveDReps = networkMetricsTotalInactiveDReps
443+
, getNetworkMetricsResponseTotalActiveCIP119CompliantDReps = networkMetricsTotalActiveCIP119CompliantDReps
444+
, getNetworkMetricsResponseTotalRegisteredDirectVoters = networkMetricsTotalRegisteredDirectVoters
440445
, getNetworkMetricsResponseAlwaysAbstainVotingPower = networkMetricsAlwaysAbstainVotingPower
441446
, getNetworkMetricsResponseAlwaysNoConfidenceVotingPower = networkMetricsAlwaysNoConfidenceVotingPower
442447
, getNetworkMetricsResponseNetworkName = networkMetricsNetworkName

govtool/backend/src/VVA/API/Types.hs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -878,17 +878,22 @@ instance ToSchema DelegationResponse where
878878

879879
data GetNetworkMetricsResponse
880880
= GetNetworkMetricsResponse
881-
{ getNetworkMetricsResponseCurrentTime :: UTCTime
882-
, getNetworkMetricsResponseCurrentEpoch :: Integer
883-
, getNetworkMetricsResponseCurrentBlock :: Integer
884-
, getNetworkMetricsResponseUniqueDelegators :: Integer
885-
, getNetworkMetricsResponseTotalDelegations :: Integer
886-
, getNetworkMetricsResponseTotalGovernanceActions :: Integer
887-
, getNetworkMetricsResponseTotalDRepVotes :: Integer
888-
, getNetworkMetricsResponseTotalRegisteredDReps :: Integer
889-
, getNetworkMetricsResponseAlwaysAbstainVotingPower :: Integer
890-
, getNetworkMetricsResponseAlwaysNoConfidenceVotingPower :: Integer
891-
, getNetworkMetricsResponseNetworkName :: Text
881+
{ getNetworkMetricsResponseCurrentTime :: UTCTime
882+
, getNetworkMetricsResponseCurrentEpoch :: Integer
883+
, getNetworkMetricsResponseCurrentBlock :: Integer
884+
, getNetworkMetricsResponseUniqueDelegators :: Integer
885+
, getNetworkMetricsResponseTotalDelegations :: Integer
886+
, getNetworkMetricsResponseTotalGovernanceActions :: Integer
887+
, getNetworkMetricsResponseTotalDRepVotes :: Integer
888+
, getNetworkMetricsResponseTotalRegisteredDReps :: Integer
889+
, getNetworkMetricsResponseTotalStakeControlledByDReps :: Integer
890+
, getNetworkMetricsResponseTotalActiveDReps :: Integer
891+
, getNetworkMetricsResponseTotalInactiveDReps :: Integer
892+
, getNetworkMetricsResponseTotalActiveCIP119CompliantDReps :: Integer
893+
, getNetworkMetricsResponseTotalRegisteredDirectVoters :: Integer
894+
, getNetworkMetricsResponseAlwaysAbstainVotingPower :: Integer
895+
, getNetworkMetricsResponseAlwaysNoConfidenceVotingPower :: Integer
896+
, getNetworkMetricsResponseNetworkName :: Text
892897
}
893898

894899
deriveJSON (jsonOptions "getNetworkMetricsResponse") ''GetNetworkMetricsResponse
@@ -903,6 +908,11 @@ exampleGetNetworkMetricsResponse =
903908
<> "\"totalGovernanceActions\": 0,"
904909
<> "\"totalDRepVotes\": 0,"
905910
<> "\"totalRegisteredDReps\": 0,"
911+
<> "\"totalStakeControlledByDReps\": 0,"
912+
<> "\"totalActiveDReps\": 0,"
913+
<> "\"totalInactiveDReps\": 0,"
914+
<> "\"totalActiveCIP119CompliantDReps\": 0,"
915+
<> "\"totalRegisteredDirectVoters\": 0,"
906916
<> "\"alwaysAbstainVotingPower\": 0,"
907917
<> "\"alwaysNoConfidenceVotingPower\": 0,"
908918
<> "\"networkName\": \"Mainnet\"}"

govtool/backend/src/VVA/DRep.hs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,21 @@ getVotes drepId selectedProposals = withPool $ \conn -> do
117117
let proposalsToSelect = if null selectedProposals
118118
then [ govActionId | (_, govActionId, _, _, _, _, _, _, _) <- results]
119119
else selectedProposals
120-
proposals <- if null proposalsToSelect
121-
then return []
122-
else Proposal.getProposals (Just proposalsToSelect)
120+
121+
allProposals <- mapM (Proposal.getProposals . Just . (:[])) proposalsToSelect
122+
123+
let proposals = concat allProposals
124+
123125
let proposalMap = M.fromList $ map (\x -> (proposalId x, x)) proposals
126+
124127
timeZone <- liftIO getCurrentTimeZone
125-
let votes = [ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date') voteTxHash'
126-
| (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date', voteTxHash') <- results
127-
, govActionId' `elem` proposalsToSelect
128-
]
128+
129+
let votes =
130+
[ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date') voteTxHash'
131+
| (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date', voteTxHash') <- results
132+
, govActionId' `elem` proposalsToSelect
133+
]
134+
129135
return (votes, proposals)
130136

131137
getDRepInfoSql :: SQL.Query

govtool/backend/src/VVA/Network.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ networkMetrics = withPool $ \conn -> do
4242
, total_gov_action_proposals
4343
, total_drep_votes
4444
, total_registered_dreps
45+
, total_stake_controlled_by_dreps
46+
, total_active_dreps
47+
, total_inactive_dreps
48+
, total_active_cip119_compliant_dreps
49+
, total_registered_direct_voters
4550
, always_abstain_voting_power
4651
, always_no_confidence_voting_power
4752
, network_name
@@ -54,6 +59,11 @@ networkMetrics = withPool $ \conn -> do
5459
total_gov_action_proposals
5560
total_drep_votes
5661
total_registered_dreps
62+
total_stake_controlled_by_dreps
63+
total_active_dreps
64+
total_inactive_dreps
65+
total_active_cip119_compliant_dreps
66+
total_registered_direct_voters
5767
always_abstain_voting_power
5868
always_no_confidence_voting_power
5969
network_name

0 commit comments

Comments
 (0)