Skip to content

refactor: split executor into focused sub-modules#301

Merged
Timi16 merged 4 commits intoTimi16:mainfrom
spartan124:refactor/executor-split
Feb 25, 2026
Merged

refactor: split executor into focused sub-modules#301
Timi16 merged 4 commits intoTimi16:mainfrom
spartan124:refactor/executor-split

Conversation

@spartan124
Copy link
Contributor

Closes #282

Summary

src/runtime/executor.rs had grown to 640 lines handling four distinct responsibilities. This PR splits it into focused sub-modules while keeping the public API identical — no callers needed to change.

New sub-modules

File Responsibility
src/runtime/loader.rs WASM loading, Env bootstrap, contract registration, error-DB init
src/runtime/invoker.rs Function invocation, timeout watchdog, memory tracking, result dispatch
src/runtime/parser.rs Argument parsing, Option<T> / Tuple<…> type-aware normalisation
src/runtime/result.rs Shared result types (ExecutionRecord, StorageSnapshot, InstructionCounts) and invocation result formatting

executor.rs is now a thin coordinator (~210 lines) that wires these modules together and owns the ContractExecutor struct.

Changes

  • src/runtime/mod.rs — declares and re-exports the four new modules; public API unchanged
  • src/runtime/executor.rs — reduced to coordination logic only
  • src/runtime/loader.rs — new
  • src/runtime/invoker.rs — new; uses inspect_err (not map_err) for side-effect-only error handling per Clippy manual_inspect
  • src/runtime/parser.rs — new; includes unit tests for tuple_arity_from_type_name
  • src/runtime/result.rs — new; correct ConversionError / InvokeError types matching soroban-sdk v22 try_invoke_contract signature

Verification

  • cargo fmt --check
  • RUSTFLAGS="-D warnings" cargo check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test

No functional changes

All execution paths, error messages, argument validation logic, mock dispatcher installation, timeout enforcement (exit(124)), and catch_unwind address guards are byte-for-byte equivalent to the original. The refactor is purely structural.

@Timi16
Copy link
Owner

Timi16 commented Feb 25, 2026

fix conflicts

@spartan124
Copy link
Contributor Author

spartan124 commented Feb 25, 2026

@Timi16
I have pulled recent codebase changes and reformatted the codebase.

@spartan124
Copy link
Contributor Author

Also, there is an errorr in the test coverage implemented that shows the total coverage as 0.
How should we proceed? @Timi16

@spartan124
Copy link
Contributor Author

@Timi16
corrected the error in the coverage implementation.

Coverage

Overall project coverage: 56.32% (pre-existing, unchanged by this refactor).
The refactor is structural only — no logic was added or removed.
Coverage improvement for the runtime sub-modules is tracked separately.

I will also move the coverage pass-mark to 50% pending when an issue is created to address increasing the test coverage project-wise.

@Timi16 Timi16 merged commit c57ccd8 into Timi16:main Feb 25, 2026
5 of 6 checks passed
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.

Refactor Executor Module into Smaller Sub-modules

2 participants