Skip to content

Commit

Permalink
Merge pull request #191 from ethpandaops/pk910/fixes
Browse files Browse the repository at this point in the history
fix sql error for consolidation/withdrawal request tx queries
  • Loading branch information
pk910 authored Dec 11, 2024
2 parents 45e50b0 + 2523365 commit 206cea9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
31 changes: 2 additions & 29 deletions clients/consensus/chainstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package consensus
import (
"bytes"
"fmt"
"math"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -182,37 +181,11 @@ func (cs *ChainState) GetFinalizedSlot() phase0.Slot {
}

func (cs *ChainState) CurrentSlot() phase0.Slot {
if cs.wallclock == nil {
return 0
}

slot, _, err := cs.wallclock.Now()
if err != nil {
return 0
}

if slot.Number() > uint64(math.MaxInt64) {
return 0
}

return phase0.Slot(slot.Number())
return cs.TimeToSlot(time.Now())
}

func (cs *ChainState) CurrentEpoch() phase0.Epoch {
if cs.wallclock == nil {
return 0
}

_, epoch, err := cs.wallclock.Now()
if err != nil {
return 0
}

if epoch.Number() > uint64(math.MaxInt64) {
return 0
}

return phase0.Epoch(epoch.Number())
return cs.EpochOfSlot(cs.CurrentSlot())
}

func (cs *ChainState) EpochOfSlot(slot phase0.Slot) phase0.Epoch {
Expand Down
4 changes: 2 additions & 2 deletions db/consolidation_request_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ func GetConsolidationRequestTxsFiltered(offset uint64, limit uint32, canonicalFo
null AS block_root,
0 AS fork_id,
null AS source_address,
0 AS source_index,
null AS source_pubkey,
0 AS target_index,
0 AS source_index,
null AS target_pubkey,
0 AS target_index,
null AS tx_hash,
null AS tx_sender,
null AS tx_target,
Expand Down
2 changes: 1 addition & 1 deletion db/withdrawal_request_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func GetWithdrawalRequestTxsFiltered(offset uint64, limit uint32, canonicalForkI
null AS block_root,
0 AS fork_id,
null AS source_address,
0 AS validator_index,
null AS validator_pubkey,
0 AS validator_index,
0 AS amount,
null AS tx_hash,
null AS tx_sender,
Expand Down

0 comments on commit 206cea9

Please sign in to comment.