mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
core/state: fix bug about getting stable LogsHash result. (#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 <175728472+Copilot@users.noreply.github.com> Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
parent
15ff378a89
commit
6420ee3592
1 changed files with 4 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
|
@ -264,6 +265,9 @@ func (s *StateDB) Logs() []*types.Log {
|
|||
for _, lgs := range s.logs {
|
||||
logs = append(logs, lgs...)
|
||||
}
|
||||
sort.Slice(logs, func(i, j int) bool {
|
||||
return logs[i].Index < logs[j].Index
|
||||
})
|
||||
return logs
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue