Skip to content

Commit e873140

Browse files
committed
get stable LogsHash result
1 parent 18a9027 commit e873140

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/state/statedb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"maps"
2424
"slices"
25+
"sort"
2526
"sync"
2627
"sync/atomic"
2728
"time"
@@ -264,6 +265,10 @@ func (s *StateDB) Logs() []*types.Log {
264265
for _, lgs := range s.logs {
265266
logs = append(logs, lgs...)
266267
}
268+
// Due to the map iteration is not stable, we need to sort the logs by TxIndex, then the LogsHash result is stable.
269+
sort.Slice(logs, func(i, j int) bool {
270+
return logs[i].TxIndex < logs[j].TxIndex
271+
})
267272
return logs
268273
}
269274

0 commit comments

Comments
 (0)