Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accounts/abi: fix MakeTopics mutation of big.Int inputs #30785

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Nov 21, 2024

#28764 updated func MakeTopics to support negative *big.Ints. However, it also changed the behavior of the function from just reading the input *big.Int via Bytes(), to leveraging big.U256Bytes which is documented as being destructive:

// U256Bytes converts a big Int into a 256bit EVM number.
// This operation is destructive.
func U256Bytes(n *big.Int) []byte {

This was flagged by the race detector in our test suite, due to sharing some fixture variables for "constants" like oneEth. Looking around the codebase, other users of this function make defensive copies, like packNum:

return math.U256Bytes(new(big.Int).Set(value.Interface().(*big.Int)))

This PR updates MakeTopics to make a copy in the same way.

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

SGTM

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

@jmank88 jmank88 requested a review from holiman as a code owner November 25, 2024 12:13
@jmank88
Copy link
Contributor Author

jmank88 commented Nov 25, 2024

LGTM,

can you also fix here? master/signer/core/apitypes/types.go#L679

Done

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman merged commit 3c754e2 into ethereum:master Nov 25, 2024
2 of 3 checks passed
@holiman holiman added this to the 1.14.13 milestone Nov 25, 2024
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.

5 participants