Repository navigation
core/vm, internal/ethapi: CAS20 creation log order and bootstrap caller, drop dead StateOverride copy - #3826
Merged
Conversation
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>
Pull Request ReviewThis 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 ContentNo sensitive content detected. Security IssuesNo serious security issues detected. Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits. |
Contributor
Author
|
Spec side: bnb-chain/BEPs#716 |
will-2012
approved these changes
Sep 18, 2026
will-2012
left a comment
Contributor
There was a problem hiding this comment.
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
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Three CAS20 follow-ups from the BEP-702 fix review:
CAS20Createdis emitted before the initial admin grant andinitCalls, the bootstrap window runs with the factory asmsg.sender, and the unusedStateOverridecopy ininternal/ethapi/api.gois removed (FR-05).Rationale
RoleGrantedandinitCallslogs it logically precedes.initCallsare calls the factory makes into the new token, so the token should see the factory asmsg.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.api.goStateOverridecopy was unreachable from RPC and lacked theDisabledPrecompilehandling of the liveoverride.Apply; a future caller pointed at it would silently lose CAS20 override routing. Its only test already exists ininternal/ethapi/override.Spec side: bnb-chain/BEPs PR for BEP-702 (linked in comments).
Example
TestCAS20CreatedEventnow pins:CAS20Createdis the first log, the initial admin'sRoleGrantedfollows, and itssenderis the factory.Changes
core/vm/cas20_factory.go: emitCAS20Createdright after the token identity is written;spawnBootstrap(addr, CAS20FactoryAddress); creationRoleGrantedsender is the factory.core/vm/cas20_factory_test.go: pin log order and sender.internal/ethapi/api.go,api_test.go: drop the deadOverrideAccount/StateOverride/Applycopy, its duplicate test and the stub only it used.🤖 Generated with Claude Code