all: update golang/x/ext and fix slice sorting fallout (#27909)
The Go authors updated golang/x/ext to change the function signature of the slices sort method. It's an entire shitshow now because x/ext is not tagged, so everyone's codebase just picked a new version that some other dep depends on, causing our code to fail building. This PR updates the dep on our code too and does all the refactorings to follow upstream...
This commit is contained in:
@@ -525,7 +525,7 @@ func (dl *diffLayer) AccountList() []common.Hash {
|
||||
dl.accountList = append(dl.accountList, hash)
|
||||
}
|
||||
}
|
||||
slices.SortFunc(dl.accountList, common.Hash.Less)
|
||||
slices.SortFunc(dl.accountList, common.Hash.Cmp)
|
||||
dl.memory += uint64(len(dl.accountList) * common.HashLength)
|
||||
return dl.accountList
|
||||
}
|
||||
@@ -563,7 +563,7 @@ func (dl *diffLayer) StorageList(accountHash common.Hash) ([]common.Hash, bool)
|
||||
for k := range storageMap {
|
||||
storageList = append(storageList, k)
|
||||
}
|
||||
slices.SortFunc(storageList, common.Hash.Less)
|
||||
slices.SortFunc(storageList, common.Hash.Cmp)
|
||||
dl.storageList[accountHash] = storageList
|
||||
dl.memory += uint64(len(dl.storageList)*common.HashLength + common.HashLength)
|
||||
return storageList, destructed
|
||||
|
||||
@@ -33,19 +33,25 @@ type weightedIterator struct {
|
||||
priority int
|
||||
}
|
||||
|
||||
func (it *weightedIterator) Less(other *weightedIterator) bool {
|
||||
func (it *weightedIterator) Cmp(other *weightedIterator) int {
|
||||
// Order the iterators primarily by the account hashes
|
||||
hashI := it.it.Hash()
|
||||
hashJ := other.it.Hash()
|
||||
|
||||
switch bytes.Compare(hashI[:], hashJ[:]) {
|
||||
case -1:
|
||||
return true
|
||||
return -1
|
||||
case 1:
|
||||
return false
|
||||
return 1
|
||||
}
|
||||
// Same account/storage-slot in multiple layers, split by priority
|
||||
return it.priority < other.priority
|
||||
if it.priority < other.priority {
|
||||
return -1
|
||||
}
|
||||
if it.priority > other.priority {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// fastIterator is a more optimized multi-layer iterator which maintains a
|
||||
@@ -155,9 +161,7 @@ func (fi *fastIterator) init() {
|
||||
}
|
||||
}
|
||||
// Re-sort the entire list
|
||||
slices.SortFunc(fi.iterators, func(a, b *weightedIterator) bool {
|
||||
return a.Less(b)
|
||||
})
|
||||
slices.SortFunc(fi.iterators, func(a, b *weightedIterator) int { return a.Cmp(b) })
|
||||
fi.initiated = false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user