Skip to content

feat(vm): check CREATE2 max depth under Osaka#6807

Open
yanghang8612 wants to merge 1 commit into
tronprotocol:release_v4.8.2from
yanghang8612:create2-depth-osaka
Open

feat(vm): check CREATE2 max depth under Osaka#6807
yanghang8612 wants to merge 1 commit into
tronprotocol:release_v4.8.2from
yanghang8612:create2-depth-osaka

Conversation

@yanghang8612
Copy link
Copy Markdown
Collaborator

What does this PR do?

Extends the CREATE2 (Program.createContract2) maximum call-depth guard so it also takes effect under the Osaka fork. The guard pushes 0 and returns when the call depth reaches MAX_DEPTH (64); it was previously gated only on allowTvmCompatibleEvm() and is now gated on allowTvmCompatibleEvm() || allowTvmOsaka().

Why are these changes required?

The ALLOW_TVM_OSAKA proposal only gates on the VERSION_4_8_2 fork and does not require ALLOW_TVM_COMPATIBLE_EVM as a prerequisite (see ProposalUtil). Osaka can therefore be active while allowTvmCompatibleEvm is still off, in which case a max-depth CREATE2 would fail to short-circuit as expected. Gating the guard on Osaka as well keeps CREATE2's max-depth behavior consistent whenever Osaka is enabled. (CREATE, CALL and the other call paths already enforce this depth check unconditionally.)

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Added OperationsTest#testCreate2MaxDepthWithOsakaOnly: enables Osaka only (allowTvmCompatibleEvm = 0, allowTvmOsaka = 1), invokes createContract2 at depth 64, and asserts that 0 is pushed onto the stack and no internal transaction is created.

Follow up

None.

Extra details

Single-line behavioral change; paths where allowTvmCompatibleEvm is enabled are unaffected.

}

@Test
public void testCreate2MaxDepthWithOsakaOnly() throws ContractValidateException {
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.

Would be great to add a test case where both allowTvmCompatibleEvm and allowTvmOsaka are false, just to explicitly confirm that CREATE2 behaves as expected when neither flag is enabled. Helps make the intent clear for future readers!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, thanks! Added testCreate2MaxDepthWithNeitherFlag in the latest push: with both allowTvmCompatibleEvm and allowTvmOsaka disabled, the MAX_DEPTH short-circuit is not taken, so at max depth CREATE2 still proceeds as before — it records an internal transaction and pushes the new contract address instead of 0. This documents the baseline behavior alongside the Osaka-only case for future readers. PTAL.

@yanghang8612 yanghang8612 force-pushed the create2-depth-osaka branch from c0126f0 to 0af1527 Compare June 2, 2026 02:32
@halibobo1205 halibobo1205 added the topic:vm VM, smart contract label Jun 3, 2026
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:vm VM, smart contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants