Skip to content

refactor(op-devstack): add capability interfaces for polymorphic lookups (Phase 3)#18874

Merged
teddyknox merged 1 commit intodevelopfrom
teddyknox/id-refactor-phase3
Feb 24, 2026
Merged

refactor(op-devstack): add capability interfaces for polymorphic lookups (Phase 3)#18874
teddyknox merged 1 commit intodevelopfrom
teddyknox/id-refactor-phase3

Conversation

@teddyknox
Copy link
Copy Markdown
Contributor

This PR introduces capability interfaces for op-devstack that enable polymorphic lookups across component types with different ID signatures. This is Phase 3 of the ID type system refactor.

Problem

Components like RollupBoostNode and OPRBuilderNode provide L2 EL functionality but can't implement L2ELNode because their ID() methods return different types:

// L2ELNode has: ID() L2ELNodeID
// RollupBoostNode has: ID() RollupBoostNodeID
// OPRBuilderNode has: ID() OPRBuilderNodeID

This forced manual multi-registry lookups:

func (o *Orchestrator) GetL2EL(id stack.L2ELNodeID) (L2ELNode, bool) {
    if el, ok := o.l2ELs.Get(id); ok {
        return el, true
    }
    rbID := stack.NewRollupBoostNodeID(id.Key(), id.ChainID())
    if rb, ok := o.rollupBoosts.Get(rbID); ok {
        return rb, true
    }
    // ... check OPRBuilder too
}

Solution

Capability interfaces capture shared behavior without the incompatible ID() method:

type L2ELCapable interface {
    L2EthClient() apis.L2EthClient
    L2EngineClient() apis.EngineClient
    ELNode
}

Polymorphic lookup by key:

sequencer, ok := FindL2ELCapableByKey(registry, "sequencer", chainID)
// Returns whichever L2ELCapable component has that key

Changes

File Description
stack/capabilities.go L2ELCapable interface and registry helpers
stack/capabilities_test.go Comprehensive test suite (9 tests)
Design document Phase 3 implementation notes

Test Plan

  • L2ELCapableKinds() returns expected kinds
  • RegistryFindByCapability finds all implementing components
  • RegistryFindByCapabilityOnChain filters by chain
  • FindL2ELCapableByKey polymorphic lookup works
  • FindL2ELCapableByKey prefers L2ELNode when multiple types share a key
  • Polymorphic scenario test demonstrates the use case

@teddyknox teddyknox requested review from a team as code owners January 20, 2026 19:56
@teddyknox teddyknox requested review from op-will and removed request for a team January 20, 2026 19:56
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase3 branch from cad37f6 to eb6a9ec Compare January 20, 2026 20:28
@teddyknox teddyknox changed the title op-devstack: add capability interfaces for polymorphic lookups (Phase 3) refactor(op-devstack): add capability interfaces for polymorphic lookups (Phase 3) Jan 21, 2026
Copy link
Copy Markdown
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Copy Markdown
Member

@pcw109550 pcw109550 left a comment

Choose a reason for hiding this comment

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

The entire files that is added in this PR is dropped at the last PR (phase 6 #18877), and also not used in phase 4, 5. Is this intended, or this specific polymorphic lookup will be addressed in the follow up PR after phase 6?

According to the design doc, FindL2ELCapableByKey should be used at the orchestrator like

func (o *Orchestrator) FindL2EL(key string, chainID eth.ChainID) (L2ELCapable, bool) {
    return stack.FindL2ELCapableByKey(o.registry, key, chainID)
}

Still approving this PR because this comment may be addressed at phase 6, the last PR.

@opgitgovernance
Copy link
Copy Markdown
Contributor

This pr has been automatically marked as stale and will be closed in 5 days if no updates

@pcw109550 pcw109550 removed the S-stale Status: Will be closed unless there is activity label Feb 19, 2026
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch 2 times, most recently from c001e43 to aecfdc2 Compare February 20, 2026 16:01
@teddyknox teddyknox requested a review from a team as a February 20, 2026 16:01
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch from aecfdc2 to 82e1be7 Compare February 20, 2026 16:02
Base automatically changed from teddyknox/id-refactor-phase2 to develop February 20, 2026 17:04
                                                                                                                                                                                                                                                                                                                           
Introduce L2ELCapable interface that captures shared behavior across                                                                                                                                                                                                                                                     
L2ELNode, RollupBoostNode, and OPRBuilderNode without requiring them to                                                                                                                                                                                                                                                  
share an ID() method signature.                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                         
This enables polymorphic lookups where code can find any L2 EL-capable                                                                                                                                                                                                                                                   
component by key+chainID, regardless of concrete type:                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                         
  sequencer, ok := FindL2ELCapableByKey(registry, "sequencer", chainID)                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                         
Previously this required manual multi-registry lookups checking each                                                                                                                                                                                                                                                     
type separately.
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase3 branch from b22581a to 6c7c339 Compare February 20, 2026 22:22
@teddyknox teddyknox added this pull request to the merge queue Feb 24, 2026
Merged via the queue into develop with commit a74ab7d Feb 24, 2026
75 checks passed
@teddyknox teddyknox deleted the teddyknox/id-refactor-phase3 branch February 24, 2026 18:03
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.

4 participants