core/types/bal: improve the bal validation (#35110)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

cb1364d60e
This commit is contained in:
rjl493456442 2026-06-05 10:44:41 +08:00 committed by GitHub
parent bc1967f088
commit 13d8df63f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,6 +178,11 @@ func isStrictlySortedFunc[S ~[]E, E any](x S, cmp func(a, b E) int) bool {
// which are ordered ascending by transaction index and contain no duplicate
// modifications for a given index.
func (e *encodingSlotChanges) validate(maxBALIndex int) error {
// Each SlotChanges entry MUST contain at least one StorageChange.
if len(e.SlotChanges) == 0 {
return errors.New("empty slot changes")
}
// Each storage key MUST appear at most once in storage_changes per account.
if !isStrictlySortedFunc(e.SlotChanges, func(a, b encodingStorageWrite) int {
return cmp.Compare(a.BlockAccessIndex, b.BlockAccessIndex)
}) {