Skip to content

Commit 9929189

Browse files
committed
clean
1 parent 185df2d commit 9929189

File tree

6 files changed

+18
-330
lines changed

6 files changed

+18
-330
lines changed

internal/config/config.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ type RewardsConfig struct {
105105
ValidateRewardsRoot bool
106106
GenerateStakerOperatorsTable bool
107107
CalculateRewardsDaily bool
108-
WithdrawalQueueWindow float64 // Duration in days for withdrawal queue period (14.0 for mainnet, 0.0069 for testnet/preprod ~10 min)
109108
RewardsV2_2Enabled bool
110109
}
111110

@@ -215,7 +214,6 @@ var (
215214
RewardsValidateRewardsRoot = "rewards.validate_rewards_root"
216215
RewardsGenerateStakerOperatorsTable = "rewards.generate_staker_operators_table"
217216
RewardsCalculateRewardsDaily = "rewards.calculate_rewards_daily"
218-
RewardsWithdrawalQueueWindow = "rewards.withdrawal_queue_window"
219217
RewardsV2_2Enabled = "rewards.v2_2_enabled"
220218

221219
EthereumRpcBaseUrl = "ethereum.rpc_url"
@@ -251,18 +249,6 @@ var (
251249
CoingeckoApiKey = "coingecko.api-key"
252250
)
253251

254-
// getDefaultWithdrawalQueueDuration returns the default withdrawal queue duration in days based on chain
255-
func getDefaultWithdrawalQueueDuration(chain Chain) float64 {
256-
switch chain {
257-
case Chain_Mainnet:
258-
return 14.0 // Mainnet uses 14-day withdrawal queue
259-
case Chain_Preprod, Chain_Holesky, Chain_Sepolia, Chain_Hoodi, Chain_PreprodHoodi:
260-
return 10.0 / (24.0 * 60.0) // Testnet/preprod uses 10 minutes = ~0.0069 days
261-
default:
262-
return 14.0 // Default to mainnet behavior
263-
}
264-
}
265-
266252
func FloatWithDefault(value, defaultValue float64) float64 {
267253
if value == 0.0 {
268254
return defaultValue
@@ -323,7 +309,6 @@ func NewConfig() *Config {
323309
ValidateRewardsRoot: viper.GetBool(normalizeFlagName(RewardsValidateRewardsRoot)),
324310
GenerateStakerOperatorsTable: viper.GetBool(normalizeFlagName(RewardsGenerateStakerOperatorsTable)),
325311
CalculateRewardsDaily: viper.GetBool(normalizeFlagName(RewardsCalculateRewardsDaily)),
326-
WithdrawalQueueWindow: FloatWithDefault(viper.GetFloat64(normalizeFlagName(RewardsWithdrawalQueueWindow)), getDefaultWithdrawalQueueDuration(chain)),
327312
RewardsV2_2Enabled: viper.GetBool(normalizeFlagName(RewardsV2_2Enabled)),
328313
},
329314

pkg/postgres/migrations/202512160000_addSlashableUntilToOperatorRegistrationSnapshots/up.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

pkg/postgres/migrations/migrator.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ import (
8383
_202507301421_crossChainRegistryTables "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202507301421_crossChainRegistryTables"
8484
_202511051502_keyRotationScheduled "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202511051502_keyRotationScheduled"
8585
_202512150000_operatorAllocationSnapshotsTable "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202512150000_operatorAllocationSnapshotsTable"
86-
_202512160000_addSlashableUntilToOperatorRegistrationSnapshots "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202512160000_addSlashableUntilToOperatorRegistrationSnapshots"
8786
_202512161200_addMaxMagnitudeToAllocationSnapshots "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202512161200_addMaxMagnitudeToAllocationSnapshots"
8887
_202601260000_uniqueAndTotalStakeRewardSubmissions "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202601260000_uniqueAndTotalStakeRewardSubmissions"
8988
)
@@ -231,7 +230,6 @@ func (m *Migrator) MigrateAll() error {
231230
&_202507301346_taskMailboxTables.Migration{},
232231
&_202511051502_keyRotationScheduled.Migration{},
233232
&_202512150000_operatorAllocationSnapshotsTable.Migration{},
234-
&_202512160000_addSlashableUntilToOperatorRegistrationSnapshots.Migration{},
235233
&_202512161200_addMaxMagnitudeToAllocationSnapshots.Migration{},
236234
&_202601260000_uniqueAndTotalStakeRewardSubmissions.Migration{},
237235
}

pkg/rewards/operatorSetOperatorRegistrationSnapshots.go

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
2222
const 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)
2424
WITH 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
127106
FROM cleaned_records
128107
CROSS 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

133111
func (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

Comments
 (0)