Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ changes.
- Fix calculating votes counting for governance actions
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)
- Remove abstain votes (not auto abstain) from total DRep stake
- Fix counting committee members [Issue 2948](https://github.com/IntersectMBO/govtool/issues/2948)

### Changed

Expand Down
27 changes: 22 additions & 5 deletions govtool/backend/sql/get-network-metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ DRepDistr AS (
CurrentEpoch AS (
SELECT MAX(no) AS no FROM epoch
),
CommitteeMembers AS (
SELECT DISTINCT ON (cm.committee_hash_id)
cr.id,
block.time,
encode(cold_key_hash.raw, 'hex') cold_key,
encode(hot_key_hash.raw, 'hex') hot_key
FROM committee_registration cr
JOIN tx ON tx.id = cr.tx_id
JOIN block ON block.id = tx.block_id
JOIN committee_hash cold_key_hash ON cr.cold_key_id = cold_key_hash.id
JOIN committee_hash hot_key_hash ON cr.hot_key_id = hot_key_hash.id
JOIN committee_member cm ON cm.committee_hash_id = cold_key_hash.id OR cm.committee_hash_id = hot_key_hash.id
LEFT JOIN committee_de_registration cdr ON cdr.cold_key_id = cold_key_hash.id
CROSS JOIN CurrentEpoch
WHERE
cdr.id IS NULL AND cm.expiration_epoch > CurrentEpoch.no
),
NoOfCommitteeMembers AS (
SELECT COUNT(*) total FROM CommitteeMembers
),
ActiveDRepBoundaryEpoch AS (
SELECT epoch_no - drep_activity AS epoch_no FROM DRepActivity
),
Expand Down Expand Up @@ -187,9 +207,6 @@ AlwaysNoConfidenceVotingPower AS (
TotalDRepDistr AS (
SELECT SUM(COALESCE(amount, 0))::bigint total_drep_distr FROM drep_distr where epoch_no = (SELECT no from CurrentEpoch)
),
CommitteeMembersCount AS (
SELECT COUNT(*) AS no_of_committee_members FROM committee_member
),
LatestGovAction AS (
SELECT gap.id, gap.enacted_epoch
FROM gov_action_proposal gap
Expand Down Expand Up @@ -223,7 +240,7 @@ SELECT
AlwaysAbstainVotingPower.amount AS always_abstain_voting_power,
AlwaysNoConfidenceVotingPower.amount AS always_no_confidence_voting_power,
meta.network_name,
CommitteeMembersCount.no_of_committee_members,
NoOfCommitteeMembers.total no_of_committee_members,
CommitteeThreshold.quorum_numerator,
CommitteeThreshold.quorum_denominator
FROM CurrentEpoch
Expand All @@ -242,6 +259,6 @@ CROSS JOIN TotalActiveCIP119CompliantDReps
CROSS JOIN TotalRegisteredDirectVoters
CROSS JOIN AlwaysAbstainVotingPower
CROSS JOIN AlwaysNoConfidenceVotingPower
CROSS JOIN CommitteeMembersCount
CROSS JOIN NoOfCommitteeMembers
CROSS JOIN CommitteeThreshold
CROSS JOIN meta;