Skip to content

Commit e671a58

Browse files
mask-ppCopilotrjl493456442
authored andcommitted
core/state: fix bug about getting stable LogsHash result. (ethereum#33082)
Because the map iteration is unstable, we need to order logs by tx index and keep the same order with receipts and their logs, so we can still get the same `LogsHash` across runs. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: rjl493456442 <[email protected]>
1 parent 5f06802 commit e671a58

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/state/statedb.go

Lines changed: 4 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,9 @@ func (s *StateDB) Logs() []*types.Log {
264265
for _, lgs := range s.logs {
265266
logs = append(logs, lgs...)
266267
}
268+
sort.Slice(logs, func(i, j int) bool {
269+
return logs[i].Index < logs[j].Index
270+
})
267271
return logs
268272
}
269273

0 commit comments

Comments
 (0)