Skip to content

Conversation

@abelmega
Copy link
Collaborator

@abelmega abelmega commented Nov 6, 2025

Summary

Adds bidirectional state transition validation to the fuzz e2e test by implementing a block reversion mechanism that rolls back all applied state changes to the initial state after forward execution completes.

Motivation

The existing fuzz test only validates forward state transitions (applying blocks). This PR enhances test coverage by also validating backward state transitions (reverting blocks), which ensures:

  1. State update invertibility: All state updates can be correctly reversed using their inverse operations
  2. Trie consistency during reversion: The trie correctly computes intermediate state roots when unwinding changes
  3. Bidirectional database operations: The database correctly handles both forward and backward state transitions

This is critical for blockchain state management where reorganizations and rollbacks are common operations.

Changes

  • Track revert data: Store (pre_state_root, inverse_updates) pairs for each block during forward execution
  • Post-test reversion: After forward validation completes, revert all blocks back to the initial state in reverse chronological order
  • Batch processing: Support configurable batch sizes via BLOCK_REVERT_STEP environment variable to test both single-block and multi-block reversion scenarios
  • State root validation: Verify that each reversion step produces the expected historical state root

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
salt/src/fuzz.rs 0.00% 27 Missing ⚠️

📢 Thoughts on this report? Let us know!

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