Skip to content

Conversation

@alarso16
Copy link
Contributor

@alarso16 alarso16 commented Dec 9, 2025

Why this should be merged

This test flakes because every once in a while, the final block hash starts with 0xef, which is incompatible with the London hard fork. It's unintuitive that the ErrInvalidCode error would be encountered for return values that are not code hashes, but this testing only fix will remove failures in CI

Closes #4560

How this works

Uses a random seed to pre-fill the state with the same data every time.

How this was tested

Locally, logging the resulting block hash.

Need to be documented in RELEASES.md?

No

@alarso16 alarso16 self-assigned this Dec 9, 2025
@alarso16 alarso16 added testing This primarily focuses on testing evm labels Dec 9, 2025
@alarso16 alarso16 marked this pull request as ready for review December 9, 2025 16:53
@alarso16 alarso16 requested a review from a team as a code owner December 9, 2025 16:53
Copilot AI review requested due to automatic review settings December 9, 2025 16:53
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 fixes a flaky test (TestTracingWithOverrides) that fails approximately 1/256 times when randomly generated block hashes start with 0xef, which conflicts with London hard fork validation rules.

Key changes:

  • Introduces deterministic account generation using a fixed random seed
  • Adds newAccountsWithSeed helper function to generate predictable test accounts

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

@alarso16 alarso16 changed the title test: Use predictable accounts fot TestTracingwithOverrides test: Use predictable accounts for TestTracingwithOverrides Dec 9, 2025
@alarso16 alarso16 requested a review from a team December 9, 2025 22:07
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Austin Larson <[email protected]>
Copy link
Contributor

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

Good work in finding that! I'd usually try to understand why it happens, but this will all be deleted in time.

@alarso16 alarso16 marked this pull request as draft December 12, 2025 17:06
@alarso16
Copy link
Contributor Author

I'm not changing the dependencies right before subnet-evm merger, so I'll just wait to push for a review

Copy link
Contributor Author

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

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

I had to update all the commits used in versioning to trick the go.mod into accepting the lower semantic version

@alarso16 alarso16 force-pushed the alarso16/tracing-overrides branch from fa6d8c3 to a55d7af Compare December 15, 2025 18:57
@alarso16 alarso16 marked this pull request as ready for review December 15, 2025 19:19
@alarso16 alarso16 requested a review from a team as a code owner December 15, 2025 19:19
@JonathanOppenheimer JonathanOppenheimer added coreth Related to the former coreth standalone repository evm Related to EVM functionality need-subnet-evm-port labels Dec 15, 2025
@alarso16 alarso16 added subnet-evm Related to the former subnet-evm standalone repository and removed need-subnet-evm-port labels Dec 15, 2025
Comment on lines +1004 to +1007
func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := 0; i < n; i++ {
binary.BigEndian.PutUint64(seed, uint64(i))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := 0; i < n; i++ {
binary.BigEndian.PutUint64(seed, uint64(i))
func UNSAFEDeterministicAccounts(t *testing.T, n uint64) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := range n {
binary.BigEndian.PutUint64(seed, i)

addr := crypto.PubkeyToAddress(key.PublicKey)
accounts = append(accounts, Account{key: key, addr: addr})
}
slices.SortFunc(accounts, func(a, b Account) int { return a.addr.Cmp(b.addr) })
Copy link
Contributor

Choose a reason for hiding this comment

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

Why sort them?

func testTracingWithOverrides(t *testing.T, scheme string) {
// Initialize test accounts
accounts := newAccounts(3)
// This test requires deterministic block hashes, since it will fail 1/256 times,Expand commentComment on line R635ResolvedCode has comments. Press enter to view.
Copy link
Contributor

Choose a reason for hiding this comment

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

Expand commentComment on line R635ResolvedCode

?

Comment on lines +1002 to +1005
func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := 0; i < n; i++ {
binary.BigEndian.PutUint64(seed, uint64(i))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func UNSAFEDeterministicAccounts(t *testing.T, n int) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := 0; i < n; i++ {
binary.BigEndian.PutUint64(seed, uint64(i))
func UNSAFEDeterministicAccounts(t *testing.T, n uint64) (accounts []Account) {
seed := make([]byte, 8) // int64 size
for i := range n {
binary.BigEndian.PutUint64(seed, i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coreth Related to the former coreth standalone repository evm Related to EVM functionality subnet-evm Related to the former subnet-evm standalone repository testing This primarily focuses on testing

Projects

Status: In Progress 🏗️

Development

Successfully merging this pull request may close these issues.

Fix TestTracingWithOverrides flake

4 participants