Skip to content

Commit 05f636d

Browse files
authored
Merge pull request #3200 from IntersectMBO/test
GovTool - v2.0.16 - candidate
2 parents 8280b1f + e563e24 commit 05f636d

Some content is hidden

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

44 files changed

+570
-358
lines changed

.github/workflows/build-from-main.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414

1515
jobs:
1616
check-build:
17-
if: contains(fromJson('["main", "staging"]'), github.ref_name)
17+
if: contains(fromJson('["main", "staging", "develop"]'), github.ref_name)
1818
environment: ${{ matrix.network }}
1919
strategy:
2020
fail-fast: false
@@ -146,7 +146,27 @@ jobs:
146146
dockerfile: ./govtool/metadata-validation/Dockerfile
147147
image: ghcr.io/${{ github.repository }}-metadata-validation
148148
qovery_container_name: govtool-metadata-validation
149-
149+
- branch: develop
150+
network: dev-govtool
151+
workdir: ./govtool/backend
152+
name: govtool-backend
153+
dockerfile: ./govtool/backend/Dockerfile.qovery
154+
image: ghcr.io/${{ github.repository }}-backend
155+
qovery_container_name: govtool-backend
156+
- branch: develop
157+
network: dev-govtool
158+
workdir: ./govtool/frontend
159+
name: govtool-frontend
160+
dockerfile: ./govtool/frontend/Dockerfile.qovery
161+
image: ghcr.io/${{ github.repository }}-frontend
162+
qovery_container_name: govtool-frontend
163+
- branch: develop
164+
network: dev-govtool
165+
workdir: ./govtool/metadata-validation
166+
name: govtool-metadata-validation
167+
dockerfile: ./govtool/metadata-validation/Dockerfile
168+
image: ghcr.io/${{ github.repository }}-metadata-validation
169+
qovery_container_name: govtool-metadata-validation
150170

151171
runs-on: ubuntu-latest
152172
steps:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ changes.
1212

1313
### Added
1414

15+
- Add support for preprod in matomo analytics [Issue 3173](https://github.com/IntersectMBO/govtool/issues/3173)
16+
1517
### Fixed
1618

1719
- hotfix for ada handle and payment address validation order [Issue 3155](https://github.com/IntersectMBO/govtool/issues/3155)
20+
- fix proposal list performance by pre-filtering active proposals [Issue 3190](https://github.com/IntersectMBO/govtool/issues/3190)
21+
- Fix wrong prefix of script based dreps in CIP-129 standard [Issue 3203](https://github.com/IntersectMBO/govtool/issues/3203)
1822

1923
### Changed
2024

25+
- Exclude network total stake and info from network metrics [Issue 3189](https://github.com/IntersectMBO/govtool/issues/3189)
26+
- Change restriction level for re-voting on governance actions [Issue 3191](https://github.com/IntersectMBO/govtool/issues/3191)
27+
2128
### Removed
2229

2330
## [v2.0.15](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.15) 2025-03-11

govtool/backend/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This is a backend application of GovTool project.
66

77
In order to run `backend` your host machine will need access to the `cardano-db-sync` postgres database. To have this database running locally you'll need:
88

9-
- `cardano-node`
10-
- `cardano-db-sync`
11-
- PostgreSQL database
9+
- [cardano-node](https://github.com/IntersectMBO/cardano-node)
10+
- [cardano-db-sync](https://github.com/IntersectMBO/cardano-db-sync)
11+
- [PostgreSQL database](https://www.postgresql.org/download/) (psql needs to be installed on your machine in order to compile the project)
1212

1313
You will need your `cardano-node` and `cardano-db-sync` to be compatible with Sancho testnet. Until these features will be merged to the master branch the new Sancho compatible versions are available as releases on [github](https://github.com/IntersectMBO/cardano-db-sync/releases). You will also need a correct `cardano-node` version. The release notes for `cardano-db-sync` usualy specify that.
1414

@@ -30,44 +30,44 @@ Due to problems with openapi3 package it's hard to build this project with plain
3030

3131
2. Get [direnv](https://direnv.net/).
3232

33-
3. Set GHC version to 9.10.1:
33+
3. Set GHC version to 9.2.8:
3434

3535
```sh
36-
ghcup install ghc 9.10.1
36+
ghcup install ghc 9.2.8
3737

38-
ghcup set ghc 9.10.1
38+
ghcup set ghc 9.2.8
3939
```
4040

4141
4. Install cabal
4242

43-
```sh
44-
ghcup install cabal
45-
ghcup set cabal
46-
```
43+
```sh
44+
ghcup install cabal
45+
ghcup set cabal
46+
```
4747

4848
5. Enter `govtool/backend` directory:
4949

5050
```sh
51-
cd govtool/backend
51+
cd govtool/backend
5252
```
5353

5454
6. Allow direnv to setup your environment:
5555

5656
```sh
57-
direnv allow
57+
direnv allow
5858
```
5959

6060
7. Update cabal & build project
6161
```sh
62-
cabal update
63-
cabal build all
62+
cabal update
63+
cabal build all
6464
```
6565
8. Create a config file. You can use `example-config.json` as a template.
6666

6767
9. Run project
68-
`sh
69-
cabal run vva-be -- --config <YOUR CONFIG FILE> start-app
70-
`
68+
```sh
69+
cabal run vva-be -- --config <YOUR CONFIG FILE> start-app
70+
```
7171
> [!WARNING]
7272
> In the context of our ongoing project enhancements, it is assumed that the executable previously known as 'vva-be' should be now officially renamed to 'govtool-backend'. This change is necessary for aligning with the updated branding and functional scope of the application and it has to be implemented in the near future as a chore and refactoring ticket. Make sure that the documentation matches the actual name of the executable.
7373

govtool/backend/app/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ startApp vvaConfig sentryService = do
122122
dRepVotingPowerCache <- newCache
123123
dRepListCache <- newCache
124124
networkMetricsCache <- newCache
125+
networkInfoCache <- newCache
126+
networkTotalStakeCache <- newCache
125127
return $ CacheEnv
126128
{ proposalListCache
127129
, getProposalCache
@@ -133,6 +135,8 @@ startApp vvaConfig sentryService = do
133135
, dRepVotingPowerCache
134136
, dRepListCache
135137
, networkMetricsCache
138+
, networkInfoCache
139+
, networkTotalStakeCache
136140
}
137141

138142
let connectionString = encodeUtf8 (dbSyncConnectionString $ getter vvaConfig)
@@ -144,6 +148,7 @@ startApp vvaConfig sentryService = do
144148

145149
exceptionHandler :: VVAConfig -> SentryService -> Maybe Request -> SomeException -> IO ()
146150
exceptionHandler vvaConfig sentryService mRequest exception = do
151+
print exception
147152
let isNotTimeoutThread x = case fromException x of
148153
Just TimeoutThread -> False
149154
_ -> True
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT
2+
(SELECT MAX(no) FROM epoch) AS current_epoch,
3+
(SELECT MAX(block_no) FROM block) AS current_block,
4+
network_name
5+
FROM
6+
meta;

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

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,6 @@ TotalActiveCIP119CompliantDReps AS (
110110
AND lve.epoch_no >= (SELECT epoch_no FROM ActiveDRepBoundaryEpoch)
111111
)))
112112
),
113-
TotalStakeControlledByActiveDReps AS (
114-
SELECT
115-
COALESCE(SUM(dd.amount), 0)::bigint AS total
116-
FROM
117-
drep_hash dh
118-
LEFT JOIN DRepDistr dd ON dd.hash_id = dh.id AND dd.rn = 1
119-
LEFT JOIN RankedDRepRegistration rd ON dd.hash_id = rd.drep_hash_id AND rd.rn = 1
120-
LEFT JOIN LatestVoteEpoch lve ON lve.drep_id = dh.id
121-
CROSS JOIN DRepActivity
122-
WHERE
123-
dd.epoch_no = (SELECT no FROM CurrentEpoch)
124-
AND COALESCE(rd.deposit, 0) >= 0
125-
AND ((DRepActivity.epoch_no - GREATEST(COALESCE(lve.epoch_no, 0), COALESCE(rd.epoch_no, 0))) <= DRepActivity.drep_activity)
126-
),
127-
CurrentBlock AS (
128-
SELECT MAX(block_no) AS block_no FROM block
129-
),
130113
UniqueDelegators AS (
131114
SELECT COUNT(DISTINCT addr_id) AS count FROM delegation_vote
132115
),
@@ -139,9 +122,6 @@ TotalGovActionProposals AS (
139122
TotalDRepVotes AS (
140123
SELECT COUNT(*) AS count FROM voting_procedure WHERE voter_role = 'DRep'
141124
),
142-
TotalStakeControlledBySPOs AS (
143-
SELECT SUM(ps.stake)::bigint AS total FROM pool_stat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
144-
),
145125
LatestExistingVotingAnchor AS (
146126
SELECT
147127
subquery.drep_registration_id,
@@ -192,18 +172,6 @@ TotalRegisteredDirectVoters AS (
192172
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = rdr.drep_hash_id
193173
WHERE rdr.rn = 1 AND COALESCE(rdr.deposit, 0) >= 0 AND (leva.url IS NULL OR hndva.value = true)
194174
),
195-
AlwaysAbstainVotingPower AS (
196-
SELECT COALESCE((SELECT amount FROM drep_hash
197-
LEFT JOIN drep_distr ON drep_hash.id = drep_distr.hash_id
198-
WHERE drep_hash.view = 'drep_always_abstain'
199-
ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
200-
),
201-
AlwaysNoConfidenceVotingPower AS (
202-
SELECT COALESCE((SELECT amount FROM drep_hash
203-
LEFT JOIN drep_distr ON drep_hash.id = drep_distr.hash_id
204-
WHERE drep_hash.view = 'drep_always_no_confidence'
205-
ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
206-
),
207175
TotalDRepDistr AS (
208176
SELECT SUM(COALESCE(amount, 0))::bigint total_drep_distr FROM drep_distr where epoch_no = (SELECT no from CurrentEpoch)
209177
),
@@ -223,42 +191,28 @@ CommitteeThreshold AS (
223191
OR (c.gov_action_proposal_id IS NULL)
224192
)
225193
SELECT
226-
CurrentEpoch.no AS epoch_no,
227-
CurrentBlock.block_no,
228194
UniqueDelegators.count AS unique_delegators,
229195
TotalDelegations.count AS total_delegations,
230196
TotalGovActionProposals.count AS total_gov_action_proposals,
231197
TotalDRepVotes.count AS total_drep_votes,
232198
TotalRegisteredDReps.unique_registrations AS total_registered_dreps,
233199
TotalDRepDistr.total_drep_distr,
234-
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_by_active_dreps,
235-
COALESCE(TotalStakeControlledBySPOs.total, 0) AS total_stake_controlled_by_spos,
236200
TotalActiveDReps.unique_active_drep_registrations AS total_active_dreps,
237201
TotalInactiveDReps.total_inactive_dreps AS total_inactive_dreps,
238202
TotalActiveCIP119CompliantDReps.unique_active_cip119_compliant_drep_registrations AS total_active_cip119_compliant_dreps,
239203
TotalRegisteredDirectVoters.unique_direct_voters AS total_registered_direct_voters,
240-
AlwaysAbstainVotingPower.amount AS always_abstain_voting_power,
241-
AlwaysNoConfidenceVotingPower.amount AS always_no_confidence_voting_power,
242-
meta.network_name,
243204
NoOfCommitteeMembers.total no_of_committee_members,
244205
CommitteeThreshold.quorum_numerator,
245206
CommitteeThreshold.quorum_denominator
246-
FROM CurrentEpoch
247-
CROSS JOIN CurrentBlock
248-
CROSS JOIN UniqueDelegators
207+
FROM UniqueDelegators
249208
CROSS JOIN TotalDRepDistr
250209
CROSS JOIN TotalDelegations
251210
CROSS JOIN TotalGovActionProposals
252211
CROSS JOIN TotalDRepVotes
253212
CROSS JOIN TotalRegisteredDReps
254-
CROSS JOIN TotalStakeControlledByActiveDReps
255-
CROSS JOIN TotalStakeControlledBySPOs
256213
CROSS JOIN TotalActiveDReps
257214
CROSS JOIN TotalInactiveDReps
258215
CROSS JOIN TotalActiveCIP119CompliantDReps
259216
CROSS JOIN TotalRegisteredDirectVoters
260-
CROSS JOIN AlwaysAbstainVotingPower
261-
CROSS JOIN AlwaysNoConfidenceVotingPower
262217
CROSS JOIN NoOfCommitteeMembers
263218
CROSS JOIN CommitteeThreshold
264-
CROSS JOIN meta;
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
LatestVotingProcedure AS (
14+
SELECT
15+
vp.*,
16+
ROW_NUMBER() OVER (PARTITION BY drep_voter ORDER BY tx_id DESC) AS rn
17+
FROM
18+
voting_procedure vp
19+
),
20+
DRepDistr AS (
21+
SELECT
22+
drep_distr.*,
23+
ROW_NUMBER() OVER (PARTITION BY drep_hash.id ORDER BY drep_distr.epoch_no DESC) AS rn
24+
FROM
25+
drep_distr
26+
JOIN drep_hash ON drep_hash.id = drep_distr.hash_id
27+
),
28+
CurrentEpoch AS (
29+
SELECT MAX(no) AS no FROM epoch
30+
),
31+
LatestVoteEpoch AS (
32+
SELECT
33+
block.epoch_no,
34+
lvp.drep_voter AS drep_id
35+
FROM
36+
LatestVotingProcedure lvp
37+
JOIN tx ON tx.id = lvp.tx_id
38+
JOIN block ON block.id = tx.block_id
39+
WHERE
40+
lvp.rn = 1
41+
),
42+
RankedDRepRegistration AS (
43+
SELECT
44+
dr.id,
45+
dr.drep_hash_id,
46+
dr.deposit,
47+
dr.voting_anchor_id,
48+
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn,
49+
encode(tx.hash, 'hex') AS tx_hash,
50+
block.epoch_no
51+
FROM
52+
drep_registration dr
53+
JOIN tx ON tx.id = dr.tx_id
54+
JOIN block ON block.id = tx.block_id
55+
),
56+
TotalStakeControlledByActiveDReps AS (
57+
SELECT
58+
COALESCE(SUM(dd.amount), 0)::bigint AS total
59+
FROM
60+
drep_hash dh
61+
LEFT JOIN DRepDistr dd ON dd.hash_id = dh.id AND dd.rn = 1
62+
LEFT JOIN RankedDRepRegistration rd ON dd.hash_id = rd.drep_hash_id AND rd.rn = 1
63+
LEFT JOIN LatestVoteEpoch lve ON lve.drep_id = dh.id
64+
CROSS JOIN DRepActivity
65+
WHERE
66+
dd.epoch_no = (SELECT no FROM CurrentEpoch)
67+
AND COALESCE(rd.deposit, 0) >= 0
68+
AND ((DRepActivity.epoch_no - GREATEST(COALESCE(lve.epoch_no, 0), COALESCE(rd.epoch_no, 0))) <= DRepActivity.drep_activity)
69+
),
70+
TotalStakeControlledBySPOs AS (
71+
SELECT SUM(ps.stake)::bigint AS total FROM pool_stat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
72+
),
73+
AlwaysAbstainVotingPower AS (
74+
SELECT COALESCE((SELECT amount FROM drep_hash
75+
LEFT JOIN drep_distr ON drep_hash.id = drep_distr.hash_id
76+
WHERE drep_hash.view = 'drep_always_abstain'
77+
ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
78+
),
79+
AlwaysNoConfidenceVotingPower AS (
80+
SELECT COALESCE((SELECT amount FROM drep_hash
81+
LEFT JOIN drep_distr ON drep_hash.id = drep_distr.hash_id
82+
WHERE drep_hash.view = 'drep_always_no_confidence'
83+
ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
84+
)
85+
SELECT
86+
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_by_active_dreps,
87+
COALESCE(TotalStakeControlledBySPOs.total, 0) AS total_stake_controlled_by_spos,
88+
AlwaysAbstainVotingPower.amount AS always_abstain_voting_power,
89+
AlwaysNoConfidenceVotingPower.amount AS always_no_confidence_voting_power
90+
FROM TotalStakeControlledByActiveDReps
91+
LEFT JOIN TotalStakeControlledBySPOs ON TRUE
92+
LEFT JOIN AlwaysAbstainVotingPower ON TRUE
93+
LEFT JOIN AlwaysNoConfidenceVotingPower ON TRUE

govtool/backend/sql/get-votes.sql

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex'), block.epoch_no as epoch_no, block.time as time, encode(vote_tx.hash, 'hex') as vote_tx_hash
2-
from voting_procedure
3-
join gov_action_proposal
4-
on gov_action_proposal.id = voting_procedure.gov_action_proposal_id
5-
join drep_hash
6-
on drep_hash.id = voting_procedure.drep_voter
7-
left join voting_anchor
8-
on voting_anchor.id = voting_procedure.voting_anchor_id
9-
join tx as gov_action_tx
10-
on gov_action_tx.id = gov_action_proposal.tx_id
11-
join tx as vote_tx
12-
on vote_tx.id = voting_procedure.tx_id
13-
join block
14-
on block.id = vote_tx.block_id
15-
where drep_hash.raw = decode(?, 'hex')
16-
order by voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id desc
1+
SELECT DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter)
2+
voting_procedure.gov_action_proposal_id,
3+
CONCAT(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index),
4+
encode(drep_hash.raw, 'hex'),
5+
LOWER(voting_procedure.vote::text),
6+
voting_anchor.url,
7+
encode(voting_anchor.data_hash, 'hex'),
8+
block.epoch_no AS epoch_no,
9+
block.time AS time,
10+
encode(vote_tx.hash, 'hex') AS vote_tx_hash
11+
FROM voting_procedure
12+
JOIN gov_action_proposal
13+
ON gov_action_proposal.id = voting_procedure.gov_action_proposal_id
14+
JOIN drep_hash
15+
ON drep_hash.id = voting_procedure.drep_voter
16+
LEFT JOIN voting_anchor ON voting_anchor.id = voting_procedure.voting_anchor_id
17+
JOIN tx AS gov_action_tx ON gov_action_tx.id = gov_action_proposal.tx_id
18+
JOIN tx AS vote_tx ON vote_tx.id = voting_procedure.tx_id
19+
JOIN block ON block.id = vote_tx.block_id
20+
WHERE drep_hash.raw = decode(?, 'hex')
21+
ORDER BY voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id DESC

0 commit comments

Comments
 (0)