Skip to content

feat(vm): improve TVM execution isolation and edge-case handling - #2

Open
lily309 wants to merge 3 commits into
masterfrom
opt/vm-execution-safety-guards
Open

feat(vm): improve TVM execution isolation and edge-case handling#2
lily309 wants to merge 3 commits into
masterfrom
opt/vm-execution-safety-guards

Conversation

@lily309

@lily309 lily309 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Background

Some TVM execution paths can be further improved when handling constant calls, nested contract execution, contract lifecycle operations, and Stake 2.0 operations.

Under specific edge conditions, the current execution flow may retain intermediate state longer than necessary or continue processing after the execution result is already determinable.

This issue tracks a set of improvements to make TVM execution more isolated, consistent, and efficient while preserving backward compatibility.

Scope

  • Optimize the lifecycle of the VM operation table for constant calls and nested CALL/CREATE execution.
  • Improve execution handling for SELFDESTRUCT and related Stake 2.0 operations, including:
    • FreezeBalanceV2
    • UnfreezeBalanceV2
    • WithdrawExpireUnfreeze
    • CancelAllUnfreezeV2
  • Strengthen contract creation validation before persisting runtime code.
  • Add test coverage for execution-state cleanup, nested execution, fork compatibility, and the affected edge cases.

Expected Behavior

  • Temporary execution state used by constant calls is limited to the current top-level VM execution.
  • Nested CALL and CREATE executions reuse the context prepared by the top-level execution.
  • Non-constant execution continues to use the established shared execution path.
  • Relevant contract lifecycle and Stake 2.0 edge cases terminate consistently without unnecessary processing.
  • Invalid contract creation metadata and code combinations are rejected before runtime code is persisted.
  • Existing execution behavior remains compatible before fork activation.

Fork Activation

The changes that affect transaction execution results are controlled by:

  • Fork version: VERSION_4_8_2_2
  • Block version: 37
  • Activation threshold: 70%

The constant-call execution-state isolation is an internal lifecycle improvement and is not controlled by the fork.

Testing

The changes should be covered by unit tests for:

  • Constant and non-constant VM execution isolation.
  • Nested CALL and CREATE execution.
  • Cleanup after normal completion, early return, and exceptions.
  • SELFDESTRUCT and Stake 2.0 edge-case handling.
  • Contract creation validation.
  • Behavior before and after VERSION_4_8_2_2 activation.

Related Work

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