Skip to content

feat: si patch#3335

Merged
annielz merged 4 commits intofeature-optimizationfrom
feat-si-patch
Sep 2, 2025
Merged

feat: si patch#3335
annielz merged 4 commits intofeature-optimizationfrom
feat-si-patch

Conversation

@annielz
Copy link
Contributor

@annielz annielz commented Sep 1, 2025

Description

patch for BSC superinstruction

Rationale

There might be an edge case when Run() encounters error during superinstruction execution. This pr handle that case.

Example

Path 1: Direct Super-instruction Execution
When executing the super-instruction directly and encountering insufficient gas
Result: Immediate ErrOutOfGas return

Final state:
pc = super-instruction start address
gas consumed = total gas cost of the super-instruction
remaining gas = original gas (no deduction since execution failed)

Path 2: Fallback to Regular Opcode Execution
When falling back to execute the 5 individual opcodes sequentially
Execution flow:
Opcode 1: executes successfully, gas deducted, pc advances
Opcode 2: executes successfully, gas deducted, pc advances
Opcode 3: encounters insufficient gas, execution fails

Final state:
pc = start address of the 3rd opcode
gas consumed = sum of gas costs for opcodes 1, 2, and 3
remaining gas = original gas - consumed gas

The above will result in diverge of gas and pc state at return. This pr will break down path 1 to path 2 at gas caused errors.

Changes

Notable changes:

  • gas related error handling at superinstruction opcode Run()

@annielz annielz changed the base branch from master to feature-optimization September 1, 2025 07:06
@annielz annielz merged commit dcf3b08 into feature-optimization Sep 2, 2025
1 check passed
constwz pushed a commit that referenced this pull request Sep 26, 2025
* feat: add handle for fail in middle of superinstruction opcode

* feat: modify block terminator and fallthrough

* Revert "feat: modify block terminator and fallthrough"

This reverts commit 1ddb74f.

* fix: mem last gas cost bug

---------

Co-authored-by: cbh876 <3930922419@qq.com>
constwz pushed a commit that referenced this pull request Oct 11, 2025
* feat: add handle for fail in middle of superinstruction opcode

* feat: modify block terminator and fallthrough

* Revert "feat: modify block terminator and fallthrough"

This reverts commit 1ddb74f.

* fix: mem last gas cost bug

---------

Co-authored-by: cbh876 <3930922419@qq.com>
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