Compare commits

...

6 Commits

Author SHA1 Message Date
satushh
445540d6fa test for eas going backward 2025-12-09 12:16:01 +00:00
satushh
d4bb4d227a Merge branch 'develop' into eas-bug 2025-12-09 12:14:11 +00:00
satushh
75dfe27091 lint 2025-11-13 16:03:58 +00:00
satushh
664c398134 Merge branch 'develop' into eas-bug 2025-11-13 15:56:05 +00:00
satushh
50bb9e0c59 changelog 2025-11-13 15:55:42 +00:00
satushh
7cdc96a8f5 prevent eas from going backward when increasing cgc 2025-11-03 16:04:34 +00:00
3 changed files with 35 additions and 0 deletions

View File

@@ -46,6 +46,14 @@ func (s *Store) UpdateCustodyInfo(ctx context.Context, earliestAvailableSlot pri
return nil
}
// When increasing custody group count, prevent earliestAvailableSlot from going backward.
if storedEarliestAvailableSlot != 0 && earliestAvailableSlot < storedEarliestAvailableSlot {
return errors.Errorf(
"cannot decrease earliest available slot from %d to %d when increasing custody group count from %d to %d",
storedEarliestAvailableSlot, earliestAvailableSlot, storedGroupCount, custodyGroupCount,
)
}
storedGroupCount, storedEarliestAvailableSlot = custodyGroupCount, earliestAvailableSlot
// Store the earliest available slot.

View File

@@ -134,6 +134,31 @@ func TestUpdateCustodyInfo(t *testing.T) {
require.Equal(t, initialSlot, storedSlot)
require.Equal(t, initialCount, storedCount)
})
t.Run("prevent earliest available slot from going backward when increasing group count", func(t *testing.T) {
const (
initialSlot = primitives.Slot(200)
initialCount = uint64(5)
newSlot = primitives.Slot(100) // Lower than initial - should be rejected
newCount = uint64(10) // Higher than initial - would trigger update
)
db := setupDB(t)
// Initialize custody info with slot 200 and group count 5
_, _, err := db.UpdateCustodyInfo(ctx, initialSlot, initialCount)
require.NoError(t, err)
// Try to increase group count (5 -> 10) but with a lower earliest slot (200 -> 100)
// This should fail because we can't move earliest available slot backward when increasing custody
_, _, err = db.UpdateCustodyInfo(ctx, newSlot, newCount)
require.ErrorContains(t, "cannot decrease earliest available slot", err)
// Verify the database wasn't updated
storedSlot, storedCount := getCustodyInfoFromDB(t, db)
require.Equal(t, initialSlot, storedSlot)
require.Equal(t, initialCount, storedCount)
})
}
func TestUpdateEarliestAvailableSlot(t *testing.T) {

View File

@@ -0,0 +1,2 @@
### Fixed
- prevent eas from going backward when increasing cgc