Skip to content

Conversation

@Mohiiit
Copy link
Member

@Mohiiit Mohiiit commented Nov 20, 2025

Save Runtime Execution Config for Restarts

Summary

Implements persistence of runtime execution configuration to ensure pre-confirmed blocks are re-executed with the same config values used during original execution, even after node restarts with different configuration.

Problem

When a node restarts with a pre-confirmed block, re-execution must use the exact same configuration (ChainConfig, VersionedConstants, and no_charge_fee) that was used during original execution. Without this, transaction receipts and state diffs would differ between original execution and re-execution, causing validation failures.

Solution

  1. New Module: Created runtime_exec_config.rs in primitives/chain_config to handle serialization of runtime execution config with version-aware ChainConfig handling

  2. Database Persistence: Added database operations to save/load RuntimeExecutionConfig on restart

  3. Re-execution Logic: Modified close_preconfirmed_block_if_exists to:

    • Load saved config from database
    • Use saved ChainConfig, VersionedConstants, and no_charge_fee for re-execution
    • Update config with current values after re-execution completes
  4. Version Handling: Implemented round-trip YAML serialization that automatically handles ChainConfig version changes

Key Changes

  • New file: madara/crates/primitives/chain_config/src/runtime_exec_config.rs - RuntimeExecutionConfig serialization
  • Modified: block_production/src/lib.rs - Save/load config on restart, use saved values for re-execution
  • Modified: db/src/rocksdb/meta.rs - Database operations for runtime exec config
  • Modified: db/src/storage.rs, db/src/lib.rs, db/src/rocksdb/mod.rs - Storage trait and implementations

Testing

  • Added test_reexecution_uses_saved_no_charge_fee_value to verify saved config is used for re-execution
  • Added serialization tests using mainnet.yaml config

Breaking Changes

None - backward compatible.

@Mohiiit Mohiiit self-assigned this Nov 20, 2025
@Mohiiit Mohiiit added the madara label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants