fix(op-supernode): guard chain container vn against torn interface read#20211
Draft
fix(op-supernode): guard chain container vn against torn interface read#20211
Conversation
Supernode.Start fires the Interop activity and chain-container goroutines in parallel. Interop's checkChainsReady immediately calls c.OptimisticAt -> c.SyncStatus, which reads c.vn while the chain container is concurrently assigning it in its restart loop. A torn two-word interface read can yield (type=*simpleVirtualNode, data=nil); the `c.vn == nil` guard returns false, the method dispatches on a nil receiver, and v.mu.Lock() panics at offset 0x58 (the mu field inside simpleVirtualNode). Protect c.vn with a sync.RWMutex and route all reads/writes through getVN/setVN helpers so every method takes one consistent snapshot. Also add nil-receiver guards on the *simpleVirtualNode methods as a defense against typed-nil interfaces slipping through in tests or future refactors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ajsutton
reviewed
Apr 21, 2026
Comment on lines
+228
to
+230
| if v == nil { | ||
| return eth.BlockID{}, ErrVirtualNodeNotRunning | ||
| } |
Contributor
There was a problem hiding this comment.
Checking if self is nil is a weird pattern - we probably should just put these checks in the calling code.
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.
Fixes panic at: https://app.circleci.com/pipelines/github/ethereum-optimism/optimism/123123/workflows/65b0b312-f33d-4a35-b114-b5941ee8719b/jobs/4873005
Supernode.Start fires the Interop activity and chain-container goroutines in parallel. Interop's checkChainsReady immediately calls c.OptimisticAt -> c.SyncStatus, which reads c.vn while the chain container is concurrently assigning it in its restart loop. A torn two-word interface read can yield (type=*simpleVirtualNode, data=nil); the
c.vn == nilguard returns false, the method dispatches on a nil receiver, and v.mu.Lock() panics at offset 0x58 (the mu field inside simpleVirtualNode).Protect c.vn with a sync.RWMutex and route all reads/writes through getVN/setVN helpers so every method takes one consistent snapshot. Also add nil-receiver guards on the *simpleVirtualNode methods as a defense against typed-nil interfaces slipping through in tests or future refactors.