Skip to content

Commit a36a9cc

Browse files
committed
fix: snapshot generation and deregistration queue check
- stakerShareSnapshots: Add '+ INTERVAL 1 day' to end_time calculation to include cutoff date snapshot (matches operatorShareSnapshots fix) - 15_goldOperatorOperatorSetUniqueStakeRewards: Fix deregistration queue check to only flag the 14-day window AFTER deregistration, not the entire period from registration to slashable_until
1 parent 28444d2 commit a36a9cc

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

pkg/rewards/15_goldOperatorOperatorSetUniqueStakeRewards.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ distinct_operators AS (
102102
WHERE rn = 1
103103
),
104104
105-
-- Step 3: Check if operators are in deregistration queue (between registration and slashable_until)
105+
-- Step 3: Check if operators are in deregistration queue (14-day window after deregistration)
106106
operators_with_deregistration_status AS (
107107
SELECT
108108
dop.*,
109109
CASE
110-
WHEN dop.snapshot > dop.registration_snapshot
110+
WHEN dop.slashable_until IS NOT NULL
111+
AND dop.snapshot > (dop.slashable_until - INTERVAL '14 days')
111112
AND dop.snapshot <= dop.slashable_until
112113
THEN TRUE
113114
ELSE FALSE

pkg/rewards/stakerShareSnapshots.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const stakerShareSnapshotsQuery = `
3333
SELECT
3434
staker, strategy, shares::numeric as shares, snapshot_time as start_time,
3535
CASE
36-
-- If the range does not have the end, use the current timestamp truncated to 0 UTC
37-
WHEN LEAD(snapshot_time) OVER (PARTITION BY staker, strategy ORDER BY snapshot_time) is null THEN date_trunc('day', TIMESTAMP '{{.cutoffDate}}')
36+
-- If the range does not have the end, use cutoff + 1 day to include cutoff date snapshot
37+
WHEN LEAD(snapshot_time) OVER (PARTITION BY staker, strategy ORDER BY snapshot_time) is null THEN date_trunc('day', TIMESTAMP '{{.cutoffDate}}') + INTERVAL '1' day
3838
ELSE LEAD(snapshot_time) OVER (PARTITION BY staker, strategy ORDER BY snapshot_time)
3939
END AS end_time
4040
FROM snapshotted_records

pkg/rewards/stakerShareSnapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ func Test_StakerShareSnapshots_V22(t *testing.T) {
14991499
// (withdrawal at log 2 < slash at log 3, so withdrawal IS affected)
15001500
res = grm.Exec(`
15011501
INSERT INTO queued_withdrawal_slashing_adjustments (staker, strategy, operator, withdrawal_block_number, withdrawal_log_index, slash_block_number, slash_multiplier, block_number, transaction_hash, log_index)
1502-
VALUES (?, ?, ?, ?, 0, ?, ?, ?, ?, ?)
1502+
VALUES (?, ?, ?, ?, 2, ?, ?, ?, ?, ?)
15031503
`, "0xstaker13", "0xstrat13", "0xoperator13", block2, block2, 0.5, block2, "tx_1001_slash", 3)
15041504
assert.Nil(t, res.Error)
15051505

0 commit comments

Comments
 (0)