Skip to content

Commit bbed5d9

Browse files
authored
Merge pull request #2961 from IntersectMBO/develop
fix(#2948): committee members calculation
2 parents 3d86187 + 93ca8ff commit bbed5d9

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ changes.
2121
- Fix calculating votes counting for governance actions
2222
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)
2323
- Remove abstain votes (not auto abstain) from total DRep stake
24+
- Fix counting committee members [Issue 2948](https://github.com/IntersectMBO/govtool/issues/2948)
2425

2526
### Changed
2627

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ DRepDistr AS (
2121
CurrentEpoch AS (
2222
SELECT MAX(no) AS no FROM epoch
2323
),
24+
CommitteeMembers AS (
25+
SELECT DISTINCT ON (cm.committee_hash_id)
26+
cr.id,
27+
block.time,
28+
encode(cold_key_hash.raw, 'hex') cold_key,
29+
encode(hot_key_hash.raw, 'hex') hot_key
30+
FROM committee_registration cr
31+
JOIN tx ON tx.id = cr.tx_id
32+
JOIN block ON block.id = tx.block_id
33+
JOIN committee_hash cold_key_hash ON cr.cold_key_id = cold_key_hash.id
34+
JOIN committee_hash hot_key_hash ON cr.hot_key_id = hot_key_hash.id
35+
JOIN committee_member cm ON cm.committee_hash_id = cold_key_hash.id OR cm.committee_hash_id = hot_key_hash.id
36+
LEFT JOIN committee_de_registration cdr ON cdr.cold_key_id = cold_key_hash.id
37+
CROSS JOIN CurrentEpoch
38+
WHERE
39+
cdr.id IS NULL AND cm.expiration_epoch > CurrentEpoch.no
40+
),
41+
NoOfCommitteeMembers AS (
42+
SELECT COUNT(*) total FROM CommitteeMembers
43+
),
2444
ActiveDRepBoundaryEpoch AS (
2545
SELECT epoch_no - drep_activity AS epoch_no FROM DRepActivity
2646
),
@@ -187,9 +207,6 @@ AlwaysNoConfidenceVotingPower AS (
187207
TotalDRepDistr AS (
188208
SELECT SUM(COALESCE(amount, 0))::bigint total_drep_distr FROM drep_distr where epoch_no = (SELECT no from CurrentEpoch)
189209
),
190-
CommitteeMembersCount AS (
191-
SELECT COUNT(*) AS no_of_committee_members FROM committee_member
192-
),
193210
LatestGovAction AS (
194211
SELECT gap.id, gap.enacted_epoch
195212
FROM gov_action_proposal gap
@@ -223,7 +240,7 @@ SELECT
223240
AlwaysAbstainVotingPower.amount AS always_abstain_voting_power,
224241
AlwaysNoConfidenceVotingPower.amount AS always_no_confidence_voting_power,
225242
meta.network_name,
226-
CommitteeMembersCount.no_of_committee_members,
243+
NoOfCommitteeMembers.total no_of_committee_members,
227244
CommitteeThreshold.quorum_numerator,
228245
CommitteeThreshold.quorum_denominator
229246
FROM CurrentEpoch
@@ -242,6 +259,6 @@ CROSS JOIN TotalActiveCIP119CompliantDReps
242259
CROSS JOIN TotalRegisteredDirectVoters
243260
CROSS JOIN AlwaysAbstainVotingPower
244261
CROSS JOIN AlwaysNoConfidenceVotingPower
245-
CROSS JOIN CommitteeMembersCount
262+
CROSS JOIN NoOfCommitteeMembers
246263
CROSS JOIN CommitteeThreshold
247264
CROSS JOIN meta;

0 commit comments

Comments
 (0)