Skip to content

[Testing] Restore exact EVM updated-register count assertion - #8629

Merged
janezpodhostnik merged 2 commits into
masterfrom
janez/flaky-test-followup-evm-registers
Aug 4, 2026
Merged

[Testing] Restore exact EVM updated-register count assertion#8629
janezpodhostnik merged 2 commits into
masterfrom
janez/flaky-test-followup-evm-registers

Conversation

@janezpodhostnik

@janezpodhostnik janezpodhostnik commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #8626, which relaxed assert.Len(state.UpdatedRegisterIDs(), 13) to
NotEmpty in the COA dryCall tests because the count varied between runs — losing the
ability to catch write-amplification regressions.

The variance is now fully characterized: the test env uses a random block ID, and
environment.uuidPartition (= sha256(blockID)[0] at txnIndex 0) selects the UUID
register. Partition 0 (probability 1/256) reuses the legacy uuid register → 12 updated
registers; all other partitions create a fresh uuid_N register → 13. This 1-in-256 case
is what made the original exact assertion flaky.

This PR restores an exact assertion via a small helper that computes the expected count
(12 or 13) from the block ID, keeping the fixture's full randomness. Both branches
verified: 15 random-block runs and 3 runs with partition 0 forced, all with -race.

Test-only change; no production code touched.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation of COA transaction register updates, including rare partitioning edge cases.
    • Ensured register-count assertions accurately reflect all expected updates.
  • Tests

    • Added coverage for deterministic register selection and transaction outcomes.
    • Updated transaction checks to verify the expected number of modified registers.

@janezpodhostnik
janezpodhostnik requested a review from a team as a code owner July 29, 2026 16:01
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The COA transaction tests now verify exact register update counts. The new helper uses SHA-256-derived UUID partition selection to allow one fewer update when the partition is zero.

Changes

COA register count validation

Layer / File(s) Summary
Partition-aware assertion helper
fvm/evm/evm_test.go
Adds SHA-256 support and centralizes expected register count calculation for UUID partitions.
COA assertion integration
fvm/evm/evm_test.go
Updates two COA transaction tests to assert the exact register count.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: turbolent

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the restored exact EVM updated-register count assertion in the test changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch janez/flaky-test-followup-evm-registers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@m-Peter m-Peter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@janezpodhostnik janezpodhostnik changed the title Restore exact EVM updated-register count assertion [Testing] Restore exact EVM updated-register count assertion Jul 31, 2026
Base automatically changed from janez/flaky-test-followup-spam-boundary to master August 4, 2026 14:24
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
fvm/evm/evm_test.go (1)

7192-7204: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add t.Helper() to the assertion helper.

assertUpdatedRegisterCount takes *testing.T and performs the assertion internally via assert.Len. Without t.Helper(), a failure reports the line inside the helper (Line 7203) instead of the call site, which makes it harder to find which sub-test failed.

♻️ Proposed fix
 func assertUpdatedRegisterCount(
 	t *testing.T,
 	ctx fvm.Context,
 	state *snapshot.ExecutionSnapshot,
 	countNonZeroPartition int,
 ) {
+	t.Helper()
 	expected := countNonZeroPartition
 	blockID := ctx.BlockHeader.ID()
 	if sha256.Sum256(blockID[:])[0] == 0 {
 		expected--
 	}
 	assert.Len(t, state.UpdatedRegisterIDs(), expected)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@fvm/evm/evm_test.go` around lines 7192 - 7204, Add t.Helper() at the start of
assertUpdatedRegisterCount, before computing expected or calling assert.Len, so
assertion failures report the caller’s location.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@fvm/evm/evm_test.go`:
- Around line 7192-7204: Add t.Helper() at the start of
assertUpdatedRegisterCount, before computing expected or calling assert.Len, so
assertion failures report the caller’s location.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ed69e619-bd94-4d1d-8895-2f6a37135712

📥 Commits

Reviewing files that changed from the base of the PR and between 4976fcc and 474d2c8.

📒 Files selected for processing (1)
  • fvm/evm/evm_test.go

@janezpodhostnik
janezpodhostnik added this pull request to the merge queue Aug 4, 2026
Merged via the queue into master with commit 1d9475f Aug 4, 2026
62 of 63 checks passed
@janezpodhostnik
janezpodhostnik deleted the janez/flaky-test-followup-evm-registers branch August 4, 2026 15:25
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.

4 participants