@@ -20,7 +20,7 @@ import (
2020// Entry Exit
2121// Since exits (deregistrations) are rounded down, we must only look at the day 2 snapshot on a pipeline run on day 3.
2222const operatorSetOperatorRegistrationSnapshotsQuery = `
23- insert into operator_set_operator_registration_snapshots (operator, avs, operator_set_id, snapshot, slashable_until )
23+ insert into operator_set_operator_registration_snapshots (operator, avs, operator_set_id, snapshot)
2424WITH state_changes as (
2525 select
2626 osor.*,
@@ -74,26 +74,7 @@ marked_statuses AS (
7474 block_time AS start_time,
7575 -- Mark the next_block_time as the end_time for the range
7676 -- Use coalesce because if the next_block_time for a registration is not closed, then we use cutoff_date
77- COALESCE(next_block_time, '{{.cutoffDate}}')::timestamp AS end_time,
78- -- Calculate slashable_until based on deregistration
79- -- Deregistrations: slashability queue for unique stake rewards
80- -- NULL = still active (no deregistration)
81- --
82- -- NOTE: Design Decision - Time vs Blocks
83- -- - Sidecar uses TIME: adds configurable days (14 days on mainnet, ~10 minutes on testnets)
84- -- - Contracts use BLOCKS: adds ~100,800 blocks (14 days * 24 * 60 * 60 / 12 sec/block)
85- -- - This matches withdrawal queue behavior (stakerShareSnapshots.go:63)
86- -- - Time is continuous; blocks can be missed on-chain (acceptable edge case)
87- -- - Daily snapshot granularity makes minute-level precision differences insignificant
88- CASE
89- WHEN next_is_active = FALSE THEN
90- -- Deregistration with slashability period (environment-specific)
91- DATE(COALESCE(next_block_time, '{{.cutoffDate}}')::timestamp) + ({{.withdrawalQueueWindow}} * INTERVAL '1 day')
92- WHEN next_is_active IS NULL THEN
93- -- Still active (no deregistration event): NULL
94- NULL
95- END AS slashable_until_date,
96- is_active
77+ COALESCE(next_block_time, '{{.cutoffDate}}')::timestamp AS end_time
9778 FROM removed_same_day_deregistrations
9879 WHERE is_active = TRUE
9980 ),
@@ -105,8 +86,7 @@ registration_windows_extra as (
10586 operator_set_id,
10687 date_trunc('day', start_time) + interval '1' day as start_time,
10788 -- End time is non-inclusive because the operator is not registered to the operator set at the end time OR it is current timestamp rounded down
108- date_trunc('day', end_time) as end_time,
109- slashable_until_date
89+ date_trunc('day', end_time) as end_time
11090 FROM registration_periods
11191),
11292-- Ignore start_time and end_time that last less than a day
@@ -122,18 +102,15 @@ SELECT
122102 operator,
123103 avs,
124104 operator_set_id,
125- d AS snapshot,
126- slashable_until_date AS slashable_until
105+ d AS snapshot
127106FROM cleaned_records
128107CROSS JOIN generate_series(DATE(start_time), DATE(end_time) - interval '1' day, interval '1' day) AS d
129- on conflict on constraint uniq_operator_set_operator_registration_snapshots
130- DO UPDATE SET slashable_until = EXCLUDED.slashable_until;
108+ on conflict on constraint uniq_operator_set_operator_registration_snapshots do nothing;
131109`
132110
133111func (r * RewardsCalculator ) GenerateAndInsertOperatorSetOperatorRegistrationSnapshots (snapshotDate string ) error {
134112 query , err := rewardsUtils .RenderQueryTemplate (operatorSetOperatorRegistrationSnapshotsQuery , map [string ]interface {}{
135- "cutoffDate" : snapshotDate ,
136- "withdrawalQueueWindow" : r .globalConfig .Rewards .WithdrawalQueueWindow ,
113+ "cutoffDate" : snapshotDate ,
137114 })
138115 if err != nil {
139116 r .logger .Sugar ().Errorw ("Failed to render operator set operator registration snapshots query" , "error" , err )
0 commit comments