Skip to content

feat(vm): implement TIP-7939 CLZ opcode#6656

Merged
CodeNinjaEvan merged 3 commits into
tronprotocol:developfrom
yanghang8612:implement-tip-7939
May 8, 2026
Merged

feat(vm): implement TIP-7939 CLZ opcode#6656
CodeNinjaEvan merged 3 commits into
tronprotocol:developfrom
yanghang8612:implement-tip-7939

Conversation

@yanghang8612
Copy link
Copy Markdown
Collaborator

@yanghang8612 yanghang8612 commented Apr 8, 2026

Summary

Implement TIP-7939 CLZ opcode (0x1e), gated behind the existing allowTvmOsaka flag.

  • New opcode: pops 1 value, pushes the number of leading zero bits (256 if zero)
  • Gas cost: 5 (LOW_TIER, matching MUL)
  • Added TRON_V1_5 version with appendOsakaOperations to support Osaka opcodes
  • Test cases cover all TIP vectors, energy cost verification, [128, 255] unsigned-cast cases, and rejection before Osaka activation
  • Scope: java-tron node-side opcode support only; compiler/tooling emission and osaka version signaling are expected to be handled separately

Related: tronprotocol/tips#838

@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Apr 8, 2026
@kuny0707 kuny0707 requested review from Federico2014 and removed request for bladehan1 April 9, 2026 04:22
Comment thread actuator/src/main/java/org/tron/core/vm/OperationActions.java
@halibobo1205 halibobo1205 added the topic:vm VM, smart contract label Apr 9, 2026
Comment thread actuator/src/main/java/org/tron/core/vm/OperationActions.java
Comment thread framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java Outdated
Comment thread framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java Outdated
Copy link
Copy Markdown
Collaborator

@CodeNinjaEvan CodeNinjaEvan left a comment

Choose a reason for hiding this comment

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

LGTM

Cover CLZ in [128, 247] to exercise the (byte) cast through
DataWord.of(byte), and pin the IllegalOperationException
when allowTvmOsaka=0.
@yanghang8612 yanghang8612 force-pushed the implement-tip-7939 branch from 01b03ad to 9f39d7e Compare May 6, 2026 03:27
@yanghang8612 yanghang8612 requested review from aiden3885 and alan-eth May 8, 2026 07:54
Copy link
Copy Markdown
Collaborator

@CodeNinjaEvan CodeNinjaEvan left a comment

Choose a reason for hiding this comment

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

LGTM

@CodeNinjaEvan CodeNinjaEvan merged commit 512ce0c into tronprotocol:develop May 8, 2026
14 of 15 checks passed
@github-project-automation github-project-automation Bot moved this to Done in java-tron May 8, 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

Status: Done

Development

Successfully merging this pull request may close these issues.

9 participants