From 0bf2f414a54c41b25a5b1e50e038616f084cfb11 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 11 Dec 2024 15:58:40 +0100 Subject: [PATCH 1/2] fix sql error for consolidation & withdrawal request queries --- db/consolidation_request_txs.go | 4 ++-- db/withdrawal_request_txs.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/consolidation_request_txs.go b/db/consolidation_request_txs.go index e420e79a..21329eb0 100644 --- a/db/consolidation_request_txs.go +++ b/db/consolidation_request_txs.go @@ -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, diff --git a/db/withdrawal_request_txs.go b/db/withdrawal_request_txs.go index 541bcd82..d7545f07 100644 --- a/db/withdrawal_request_txs.go +++ b/db/withdrawal_request_txs.go @@ -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, From 2523365b686e141c7ee4cc2f4b75f5287c2beac7 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 11 Dec 2024 15:59:38 +0100 Subject: [PATCH 2/2] fix unneccesarry heap allocations from ChainState.CurrentEpoch/CurrentSlot --- clients/consensus/chainstate.go | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/clients/consensus/chainstate.go b/clients/consensus/chainstate.go index 562ac386..abc240a4 100644 --- a/clients/consensus/chainstate.go +++ b/clients/consensus/chainstate.go @@ -3,7 +3,6 @@ package consensus import ( "bytes" "fmt" - "math" "strings" "sync" "time" @@ -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 {