Skip to content

Conversation

@eomti-wm
Copy link
Contributor

@eomti-wm eomti-wm commented Jan 21, 2026

Summary
This PR addresses two key objectives:

  • enforcing ERC20 standard behavior in NativeCoinAdapter
  • enhancing tracer functionality to correctly support and verify NativeManager operations.

Changes

  1. NativeCoinAdapter ERC20 Compliance

    • Ensure NativeCoinAdapter strictly follows ERC20 standard behavior.
    • Change: Modified mint and transfer operations in core/vm/native_manager.go.
    • Detail: Replaced evm.Call with direct implementation nativeTransfer. This ensures that token transfers modify balances without invoking the recipient's receive or fallback functions, aligning with the passive nature of standard ERC20 transfers.
  2. NativeManager Tracing Support

    • Enable accurate tracing of NativeManager operations (mint, burn, transfer, blacklist).
    • Change: Implemented the CaptureEnter hook in native/prestate.go.
    • Detail: This ensures that the tracer correctly identifies and captures the pre-state of all addresses involved in NativeManager operations, even when state changes occur directly via nativeTransfer.
  3. Tracer Test Framework Refactor

    • Refactor: Updated prestate_test.go to use Go generics (testcase[T]), resolving uint64 precision loss during JSON unmarshaling to interface{}.
    • Environment: Added InjectContracts logic to test runners to correctly simulate the Anzeon system contract environment.
  4. Test Coverage Expansion

    • Added exhaustive test cases for NativeCoinAdapter (mint, burn, transfer) and AccountManager (blacklist).
      • (Note: authorized tests were omitted as the logic is identical to blacklist.)
    • Verified behavior across all tracer types: prestate_tracer, call_tracer, and call_tracer_flat.

- Replace `evm.Call` with direct balance updates in coinManager.
- Prevent invoking `receive`/`fallback` functions on recipient contracts, aligning with standard ERC20 behavior.
Refactor the prestate tracer test framework to use generics, resolving precision issues with uint64 fields (e.g., nonce, extra) during JSON marshaling.
Also, inject Anzeon system contracts into the genesis block for call tracer and flat call tracer tests to properly support NativeManager operations.

- Refactor `prestate_test.go` to use `testcase[T any]`
- Fix `uint64` parsing issues in `account` struct
- Inject system contracts in `calltrace_test.go` and `flat_calltrace_test.go`
Update the suicide_anzeon test case to correctly reflect the missing baseFee distribution in the trace result.

- Update `suicide_anzeon.json` result to include correct balance changes
Enhance the prestate tracer to correctly capture state changes induced by NativeManager operations.
Add `CaptureEnter` hook to track addresses involved in native calls.

- Implement `CaptureEnter` in `native/prestate.go` for address lookup
Add comprehensive tracer test cases for NativeManager operations, including NativeCoinAdapter (mint, burn, transfer) and AccountManager (blacklist).
Cover prestate, call, and flat call tracers.

- Add `native_coin_adapter_{mint,burn,transfer}.json`
- Add `account_manager_blacklist.json`
@eomti-wm eomti-wm added this to the Launch StableNet Testnet milestone Jan 21, 2026
@eomti-wm eomti-wm self-assigned this Jan 21, 2026
@eomti-wm eomti-wm added enhancement New feature or request stablenet feature feature for stable chain labels Jan 21, 2026
Copy link
Member

@0xmhha 0xmhha left a comment

Choose a reason for hiding this comment

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

LGTM

@eomti-wm eomti-wm merged commit 89cb185 into dev Jan 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request stablenet feature feature for stable chain

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants