Skip to content

Conversation

@mask-pp
Copy link
Contributor

@mask-pp mask-pp commented Nov 2, 2025

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.

Copilot AI review requested due to automatic review settings November 2, 2025 14:27
@mask-pp mask-pp requested a review from rjl493456442 as a code owner November 2, 2025 14:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses non-deterministic log ordering by ensuring logs are returned in a stable, consistent order. Map iteration in Go is intentionally randomized, which can cause the Logs() method to return logs in different orders across multiple calls, potentially affecting hash calculations like LogsHash.

  • Added sorting of logs by TxIndex to ensure deterministic ordering
  • Imported the sort package to support the sorting operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mask-pp mask-pp changed the title core/state: get stable LogsHash result core/state: fix bug about getting stable LogsHash result. Nov 2, 2025
@mask-pp mask-pp requested a review from rjl493456442 November 4, 2025 05:45
Removed comment about sorting logs by TxIndex.
@rjl493456442 rjl493456442 merged commit 6420ee3 into ethereum:master Nov 7, 2025
13 of 18 checks passed
@rjl493456442 rjl493456442 added this to the 1.16.8 milestone Nov 7, 2025
wit765 added a commit to wit765/XDPoSChain that referenced this pull request Nov 12, 2025
wit765 added a commit to wit765/XDPoSChain that referenced this pull request Nov 12, 2025
wit765 added a commit to wit765/XDPoSChain that referenced this pull request Nov 12, 2025
AnilChinchawale pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Nov 14, 2025
atkinsonholly pushed a commit to atkinsonholly/ephemery-geth that referenced this pull request Nov 24, 2025
…3082)

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]>
prestoalvarez pushed a commit to prestoalvarez/go-ethereum that referenced this pull request Nov 27, 2025
…3082)

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]>
fjl pushed a commit to lightclient/go-ethereum that referenced this pull request Nov 28, 2025
…3082)

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants