Skip to content

Commit c9ae937

Browse files
authored
Merge pull request #569 from ethpandaops/bbusa/dora-proposals
feat: add proposals overview
2 parents 5bb9837 + a32a54d commit c9ae937

3 files changed

Lines changed: 46 additions & 18 deletions

File tree

handlers/index.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func buildIndexPageRecentEpochsData(pageData *models.IndexPageData, currentEpoch
373373
pageData.RecentEpochs = make([]*models.IndexPageDataEpochs, 0)
374374

375375
chainState := services.GlobalBeaconService.GetChainState()
376+
specs := chainState.GetSpecs()
376377

377378
epochsData := services.GlobalBeaconService.GetDbEpochs(uint64(currentEpoch), uint32(recentEpochCount))
378379
for i := 0; i < len(epochsData); i++ {
@@ -384,14 +385,21 @@ func buildIndexPageRecentEpochsData(pageData *models.IndexPageData, currentEpoch
384385
if epochData.Eligible > 0 {
385386
voteParticipation = float64(epochData.VotedTarget) * 100.0 / float64(epochData.Eligible)
386387
}
388+
proposalParticipation := float64(0)
389+
if specs.SlotsPerEpoch > 0 {
390+
proposalParticipation = float64(epochData.BlockCount) * 100.0 / float64(specs.SlotsPerEpoch)
391+
}
387392
pageData.RecentEpochs = append(pageData.RecentEpochs, &models.IndexPageDataEpochs{
388-
Epoch: epochData.Epoch,
389-
Ts: chainState.EpochToTime(phase0.Epoch(epochData.Epoch)),
390-
Finalized: uint64(finalizedEpoch) > 0 && uint64(finalizedEpoch) >= epochData.Epoch,
391-
Justified: uint64(justifiedEpoch) > 0 && uint64(justifiedEpoch) >= epochData.Epoch,
392-
EligibleEther: epochData.Eligible,
393-
TargetVoted: epochData.VotedTarget,
394-
VoteParticipation: voteParticipation,
393+
Epoch: epochData.Epoch,
394+
Ts: chainState.EpochToTime(phase0.Epoch(epochData.Epoch)),
395+
Finalized: uint64(finalizedEpoch) > 0 && uint64(finalizedEpoch) >= epochData.Epoch,
396+
Justified: uint64(justifiedEpoch) > 0 && uint64(justifiedEpoch) >= epochData.Epoch,
397+
EligibleEther: epochData.Eligible,
398+
TargetVoted: epochData.VotedTarget,
399+
VoteParticipation: voteParticipation,
400+
BlockCount: uint64(epochData.BlockCount),
401+
SlotsPerEpoch: specs.SlotsPerEpoch,
402+
ProposalParticipation: proposalParticipation,
395403
})
396404
}
397405
pageData.RecentEpochCount = uint64(len(pageData.RecentEpochs))

templates/index/recentEpochs.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ <h5 class="card-title d-flex justify-content-between align-items-center" style="
1616
<th>Final</th>
1717
<th>Eligible (ETH)</th>
1818
<th>Voted</th>
19+
<th>Proposals</th>
1920
</tr>
2021
</thead>
2122
<tbody class="template-tbody">
@@ -33,17 +34,25 @@ <h5 class="card-title d-flex justify-content-between align-items-center" style="
3334
<td data-bind="text: $root.formatEth(eligible)"></td>
3435
<td>
3536
<div style="position:relative;width:inherit;height:inherit;">
36-
<span data-bind="text: $root.formatEth(voted)"></span> <small class="text-muted ml-3" data-bind="text: '(' + $root.formatFloat(votep, 2) + '%)'"></small>
37+
<small><span data-bind="text: $root.formatEth(voted)"></span> <span class="text-muted" data-bind="text: '(' + $root.formatFloat(votep, 2) + '%)'"></span></small>
3738
<div class="progress" style="position:absolute;bottom:-6px;width:100%;height:4px;">
3839
<div class="progress-bar" role="progressbar" data-bind="style: {width: $root.formatFloat(votep, 2)+'%'}, attr: {'aria-valuenow': $root.formatFloat(votep, 2)+'%'}" aria-valuemin="0" aria-valuemax="100"></div>
3940
</div>
4041
</div>
4142
</td>
43+
<td>
44+
<div style="position:relative;width:inherit;height:inherit;">
45+
<span data-bind="text: blocks + '/' + slots_per_epoch"></span> <small class="text-muted ml-1" data-bind="text: '(' + $root.formatFloat(proposalp, 1) + '%)'"></small>
46+
<div class="progress" style="position:absolute;bottom:-6px;width:100%;height:4px;">
47+
<div class="progress-bar" role="progressbar" data-bind="style: {width: $root.formatFloat(proposalp, 1)+'%'}, attr: {'aria-valuenow': $root.formatFloat(proposalp, 1)+'%'}" aria-valuemin="0" aria-valuemax="100"></div>
48+
</div>
49+
</div>
50+
</td>
4251
</tr>
4352
{{ html "<!-- /ko -->" }}
4453
{{ html "<!-- ko if: epochs().length == 0 -->" }}
4554
<tr class="template-row">
46-
<td style="text-align: center;" colspan="5">
55+
<td style="text-align: center;" colspan="6">
4756
no epochs found
4857
</td>
4958
</tr>
@@ -65,17 +74,25 @@ <h5 class="card-title d-flex justify-content-between align-items-center" style="
6574
<td>{{ formatEthAddCommasFromGwei $epoch.EligibleEther }}</td>
6675
<td>
6776
<div style="position:relative;width:inherit;height:inherit;">
68-
{{ formatEthAddCommasFromGwei $epoch.TargetVoted }} <small class="text-muted ml-3">({{ formatFloat $epoch.VoteParticipation 2 }}%)</small>
77+
<small>{{ formatEthAddCommasFromGwei $epoch.TargetVoted }} <span class="text-muted">({{ formatFloat $epoch.VoteParticipation 2 }}%)</span></small>
6978
<div class="progress" style="position:absolute;bottom:-6px;width:100%;height:4px;">
7079
<div class="progress-bar" role="progressbar" style="width: {{ formatFloat $epoch.VoteParticipation 2 }}%;" aria-valuenow="{{ formatFloat $epoch.VoteParticipation 2 }}%" aria-valuemin="0" aria-valuemax="100"></div>
7180
</div>
7281
</div>
7382
</td>
83+
<td>
84+
<div style="position:relative;width:inherit;height:inherit;">
85+
{{ $epoch.BlockCount }}/{{ $epoch.SlotsPerEpoch }} <small class="text-muted ml-1">({{ formatFloat $epoch.ProposalParticipation 1 }}%)</small>
86+
<div class="progress" style="position:absolute;bottom:-6px;width:100%;height:4px;">
87+
<div class="progress-bar" role="progressbar" style="width: {{ formatFloat $epoch.ProposalParticipation 1 }}%;" aria-valuenow="{{ formatFloat $epoch.ProposalParticipation 1 }}%" aria-valuemin="0" aria-valuemax="100"></div>
88+
</div>
89+
</div>
90+
</td>
7491
</tr>
7592
{{ end }}
7693
{{ else }}
7794
<tr>
78-
<td style="text-align: center;" colspan="5">
95+
<td style="text-align: center;" colspan="6">
7996
no epochs found
8097
</td>
8198
</tr>

types/models/indexPage.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ type IndexPageDataForks struct {
5555
}
5656

5757
type IndexPageDataEpochs struct {
58-
Epoch uint64 `json:"epoch"`
59-
Ts time.Time `json:"ts"`
60-
Finalized bool `json:"finalized"`
61-
Justified bool `json:"justified"`
62-
EligibleEther uint64 `json:"eligible"`
63-
TargetVoted uint64 `json:"voted"`
64-
VoteParticipation float64 `json:"votep"`
58+
Epoch uint64 `json:"epoch"`
59+
Ts time.Time `json:"ts"`
60+
Finalized bool `json:"finalized"`
61+
Justified bool `json:"justified"`
62+
EligibleEther uint64 `json:"eligible"`
63+
TargetVoted uint64 `json:"voted"`
64+
VoteParticipation float64 `json:"votep"`
65+
BlockCount uint64 `json:"blocks"`
66+
SlotsPerEpoch uint64 `json:"slots_per_epoch"`
67+
ProposalParticipation float64 `json:"proposalp"`
6568
}
6669

6770
type IndexPageDataBlocks struct {

0 commit comments

Comments
 (0)