Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BEDS-968): Return slot instead of block number for proposals #1170

Merged
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
27 changes: 11 additions & 16 deletions backend/pkg/api/data_access/vdb_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,16 +1701,14 @@ func (d *DataAccessService) GetValidatorDashboardProposalSummaryValidators(ctx c

// Build the query and get the data
var queryResult []struct {
Slot uint64 `db:"slot"`
Block sql.NullInt64 `db:"exec_block_number"`
Status string `db:"status"`
ValidatorIndex uint64 `db:"proposer"`
Slot uint64 `db:"slot"`
Status string `db:"status"`
ValidatorIndex uint64 `db:"proposer"`
}

ds = goqu.Dialect("postgres").
Select(
goqu.L("b.slot"),
goqu.L("b.exec_block_number"),
goqu.L("b.status"),
goqu.L("b.proposer")).
From(goqu.L("blocks b")).
Expand Down Expand Up @@ -1747,10 +1745,7 @@ func (d *DataAccessService) GetValidatorDashboardProposalSummaryValidators(ctx c
if _, ok := proposedValidatorMap[row.ValidatorIndex]; !ok {
proposedValidatorMap[row.ValidatorIndex] = make([]uint64, 0)
}
if !row.Block.Valid {
return nil, fmt.Errorf("error no block number for slot %v found", row.Slot)
}
proposedValidatorMap[row.ValidatorIndex] = append(proposedValidatorMap[row.ValidatorIndex], uint64(row.Block.Int64))
proposedValidatorMap[row.ValidatorIndex] = append(proposedValidatorMap[row.ValidatorIndex], row.Slot)
} else {
if _, ok := missedValidatorMap[row.ValidatorIndex]; !ok {
missedValidatorMap[row.ValidatorIndex] = make([]uint64, 0)
Expand All @@ -1759,16 +1754,16 @@ func (d *DataAccessService) GetValidatorDashboardProposalSummaryValidators(ctx c
}
}

for validatorIndex, blockNumbers := range proposedValidatorMap {
result.Proposed = append(result.Proposed, t.IndexBlocks{
Index: validatorIndex,
Blocks: blockNumbers,
for validatorIndex, slotNumbers := range proposedValidatorMap {
result.Proposed = append(result.Proposed, t.IndexSlots{
Index: validatorIndex,
Slots: slotNumbers,
})
}
for validatorIndex, slotNumbers := range missedValidatorMap {
result.Missed = append(result.Missed, t.IndexBlocks{
Index: validatorIndex,
Blocks: slotNumbers,
result.Missed = append(result.Missed, t.IndexSlots{
Index: validatorIndex,
Slots: slotNumbers,
})
}

Expand Down
8 changes: 4 additions & 4 deletions backend/pkg/api/handlers/handler_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ func mapVDBIndices(indices interface{}) ([]types.VDBSummaryValidatorsData, error

case *types.VDBProposalSummaryValidators:
return []types.VDBSummaryValidatorsData{
mapIndexBlocksSlice("proposal_proposed", v.Proposed),
mapIndexBlocksSlice("proposal_missed", v.Missed),
mapIndexSlotsSlice("proposal_proposed", v.Proposed),
mapIndexSlotsSlice("proposal_missed", v.Missed),
}, nil

default:
Expand Down Expand Up @@ -492,9 +492,9 @@ func mapIndexTimestampSlice(category string, validators []types.IndexTimestamp)
)
}

func mapIndexBlocksSlice(category string, validators []types.IndexBlocks) types.VDBSummaryValidatorsData {
func mapIndexSlotsSlice(category string, validators []types.IndexSlots) types.VDBSummaryValidatorsData {
return mapSlice(category, validators,
func(v types.IndexBlocks) (uint64, []uint64) { return v.Index, v.Blocks },
func(v types.IndexSlots) (uint64, []uint64) { return v.Index, v.Slots },
)
}

Expand Down
4 changes: 2 additions & 2 deletions backend/pkg/api/types/data_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ type VDBSlashingsSummaryValidators struct {
}

type VDBProposalSummaryValidators struct {
Proposed []IndexBlocks
Missed []IndexBlocks
Proposed []IndexSlots
Missed []IndexSlots
}

type VDBProtocolModes struct {
Expand Down
Loading