Skip to content

Commit

Permalink
fix order of requests from cahce (order by descending block index)
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 7, 2025
1 parent f588da2 commit 481894e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/chainservice_consolidations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethpandaops/dora/db"
"github.com/ethpandaops/dora/dbtypes"
"github.com/ethpandaops/dora/indexer/beacon"
"github.com/prysmaticlabs/prysm/v5/container/slice"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -211,6 +212,7 @@ func (bs *ChainService) GetConsolidationRequestOperationsByFilter(filter *dbtype
}

consolidationRequests := block.GetDbConsolidationRequests(bs.beaconIndexer)
slice.Reverse(consolidationRequests) // reverse as other datasources are ordered by descending block index too
for idx, consolidationRequest := range consolidationRequests {
if filter.MinSrcIndex > 0 && (consolidationRequest.SourceIndex == nil || *consolidationRequest.SourceIndex < filter.MinSrcIndex) {
continue
Expand Down
2 changes: 2 additions & 0 deletions services/chainservice_withdrawals.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethpandaops/dora/db"
"github.com/ethpandaops/dora/dbtypes"
"github.com/ethpandaops/dora/indexer/beacon"
"github.com/prysmaticlabs/prysm/v5/container/slice"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -197,6 +198,7 @@ func (bs *ChainService) GetWithdrawalRequestOperationsByFilter(filter *dbtypes.W
}

withdrawalRequests := block.GetDbWithdrawalRequests(bs.beaconIndexer)
slice.Reverse(withdrawalRequests) // reverse as other datasources are ordered by descending block index too
for idx, withdrawalRequest := range withdrawalRequests {
if filter.MinIndex > 0 && (withdrawalRequest.ValidatorIndex == nil || *withdrawalRequest.ValidatorIndex < filter.MinIndex) {
continue
Expand Down

0 comments on commit 481894e

Please sign in to comment.