Skip to content

core/vm, internal/ethapi: CAS20 creation log order and bootstrap caller, drop dead StateOverride copy - #3826

Merged
joey0612 merged 3 commits into
bnb-chain:developfrom
zlacfzy:cas20/created-event-order
Sep 23, 2026
Merged

joey0612 merged 3 commits into
bnb-chain:developfrom
zlacfzy:cas20/created-event-order

Conversation

@zlacfzy

@zlacfzy zlacfzy commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Description

Three CAS20 follow-ups from the BEP-702 fix review: CAS20Created is emitted before the initial admin grant and initCalls, the bootstrap window runs with the factory as msg.sender, and the unused StateOverride copy in internal/ethapi/api.go is removed (FR-05).

Rationale

  • The creation event is the token's identity record; emitting it last put it after the RoleGranted and initCalls logs it logically precedes.
  • initCalls are calls the factory makes into the new token, so the token should see the factory as msg.sender, as for any contract the factory calls. Running them as the creator let the factory act in the creator's name (approve, transfer, burn, the renounce methods), a power no ordinary caller has.
  • The api.go StateOverride copy was unreachable from RPC and lacked the DisabledPrecompile handling of the live override.Apply; a future caller pointed at it would silently lose CAS20 override routing. Its only test already exists in internal/ethapi/override.

Spec side: bnb-chain/BEPs PR for BEP-702 (linked in comments).

Example

go test ./core/vm/ ./internal/ethapi/ ./internal/ethapi/override/ -count=1

TestCAS20CreatedEvent now pins: CAS20Created is the first log, the initial admin's RoleGranted follows, and its sender is the factory.

Changes

  • core/vm/cas20_factory.go: emit CAS20Created right after the token identity is written; spawnBootstrap(addr, CAS20FactoryAddress); creation RoleGranted sender is the factory.
  • core/vm/cas20_factory_test.go: pin log order and sender.
  • internal/ethapi/api.go, api_test.go: drop the dead OverrideAccount/StateOverride/Apply copy, its duplicate test and the stub only it used.

🤖 Generated with Claude Code

zlacfzy and others added 3 commits September 17, 2026 20:11
CAS20Created is the token's identity record. Emit it as soon as that
identity is written, ahead of the initial RoleGranted and whatever the
initCalls log, so a creation transaction's logs read in the order the
state was built. The event test pins the order.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
initCalls are calls the factory makes into the new token, so the token
should see the factory as msg.sender, as it would for any contract the
factory called. Running them as the creator let the factory act in the
creator's name: approve, transfer, burn and the renounce methods inside
the window operated on the creator's balances and roles, a power no
ordinary caller of the token has. The initial admin's RoleGranted names
the factory as sender for the same reason.

No test relied on the old caller; the event test now pins the new one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
internal/ethapi/override owns OverrideAccount, StateOverride and Apply,
and every RPC path uses that package. The copy left in api.go was
reachable only from a test that the override package already carries,
and it lacked the DisabledPrecompile handling the live Apply gained, so a
future caller pointed at it would silently lose CAS20 override routing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

Pull Request Review

This Go-based EVM/blockchain PR changes CAS20 creation so the creation event is emitted before role and initialization logs, while bootstrap calls and the initial RoleGranted event identify the CAS20 factory as the caller. It also updates tests to enforce the new log order and sender, and removes an unused duplicate StateOverride implementation and its test scaffolding from internal/ethapi.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@zlacfzy

zlacfzy commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Spec side: bnb-chain/BEPs#716

@will-2012 will-2012 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Logs will affect receipt root.

zlacfzy added a commit to bnb-chain/reth-bsc that referenced this pull request Sep 23, 2026
Match bnb-chain/bsc#3826 at 159ccdf88baac7fb07e9a5638cfe613f341e715d: emit CAS20Created before the initial admin grant and initCalls, and use the factory as bootstrap caller and RoleGranted sender.

Cover both token variants, caller-owned balances and allowances, failed bootstrap rollback, and post-renunciation role freezing. Regenerate the golden trace from the Go reference.

Validation: cargo test --lib -- --test-threads=1 (620 passed, 1 ignored); cargo clippy --all-targets; rustfmt checks for modified Rust files.
@joey0612
joey0612 merged commit 37417a0 into bnb-chain:develop Sep 23, 2026
8 checks passed
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.

3 participants