Skip to content

refactor(op-devstack): add unified Registry for component storage (Phase 2)#18873

Merged
teddyknox merged 1 commit intodevelopfrom
teddyknox/id-refactor-phase2
Feb 20, 2026
Merged

refactor(op-devstack): add unified Registry for component storage (Phase 2)#18873
teddyknox merged 1 commit intodevelopfrom
teddyknox/id-refactor-phase2

Conversation

@teddyknox
Copy link
Copy Markdown
Contributor

@teddyknox teddyknox commented Jan 20, 2026

This PR introduces a unified Registry type for op-devstack that can replace the 14+ separate locks.RWMap instances currently used in the Orchestrator. This is Phase 2 of the ID type system refactor.

Problem

The current Orchestrator maintains separate registries for each component type:

type Orchestrator struct {
    batchers        locks.RWMap[stack.L2BatcherID, *L2Batcher]
    proposers       locks.RWMap[stack.L2ProposerID, *L2Proposer]
    challengers     locks.RWMap[stack.L2ChallengerID, *L2Challenger]
    l2ELs           locks.RWMap[stack.L2ELNodeID, L2ELNode]
    rollupBoosts    locks.RWMap[stack.RollupBoostNodeID, *RollupBoostNode]
    // ... 9 more
}

This leads to:

  • No unified way to query "all components on chain X"
  • Manual polymorphic lookups (checking multiple registries)
  • Adding new component types requires new registry fields

Solution

A single Registry with secondary indexes:

type Registry struct {
    components map[ComponentID]any           // Primary storage
    byKind     map[ComponentKind][]ComponentID  // "All batchers"
    byChainID  map[eth.ChainID][]ComponentID    // "All on chain 420"
}

Type-safe access via generic functions:

// Register and retrieve with compile-time type safety
RegistryRegister(r, batcherID, batcher)
batcher, ok := RegistryGet[*L2Batcher](r, batcherID)

// Query by kind or chain
batchers := RegistryGetByKind[*L2Batcher](r, KindL2Batcher)
components := RegistryGetByChainID[*L2Batcher](r, chainID)

Changes

File Description
stack/registry.go Unified Registry implementation
stack/registry_test.go Comprehensive test suite (21 tests)
stack/component_id.go Added HasChainID() helper
Design document Phase 2 implementation notes

Test Plan

  • Basic CRUD operations (Register, Get, Has, Unregister)
  • Secondary index queries (GetByKind, GetByChainID)
  • All three ID shapes (key+chain, chain-only, key-only)
  • Replace behavior (same ID registered twice)
  • Index cleanup on unregister
  • Concurrent access safety
  • Type-safe generic accessors
  • Range iteration with early termination

Migration Path

This is non-breaking. The Registry can coexist with existing locks.RWMap fields:

  1. Orchestrator can optionally maintain a Registry alongside existing maps
  2. New code can use Registry, old code continues using maps
  3. Phase 3 will add capability interfaces for polymorphic lookups
  4. Phase 4 will migrate Orchestrator to use Registry exclusively

@teddyknox teddyknox requested review from a team as code owners January 20, 2026 19:55
@teddyknox teddyknox requested review from smartcontracts and removed request for a team January 20, 2026 19:55
Comment thread op-devstack/stack/registry.go
@teddyknox teddyknox changed the title op-devstack: add unified Registry for component storage (Phase 2) refactor(op-devstack): add unified Registry for component storage (Phase 2) 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.

Comment thread op-devstack/stack/registry.go
Comment thread op-devstack/stack/registry.go
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase1 branch from 6c97f16 to e52819a Compare February 4, 2026 19:41
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch from 26da050 to a1d12d8 Compare February 4, 2026 20:07
Base automatically changed from teddyknox/id-refactor-phase1 to develop February 4, 2026 20:34
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch from a1d12d8 to 9d4e7af Compare February 20, 2026 01:52
@teddyknox teddyknox added this pull request to the merge queue Feb 20, 2026
@teddyknox teddyknox removed this pull request from the merge queue due to a manual request Feb 20, 2026
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch from c001e43 to aecfdc2 Compare February 20, 2026 16:01
@teddyknox teddyknox requested a review from a team as a code owner February 20, 2026 16:01
                                                                                                                                                                                                                                                                                                                           
Introduce a unified Registry type that can replace the 14+ separate                                                                                                                                                                                                                                                      
locks.RWMap instances in the Orchestrator. The Registry provides:                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                         
- Single map storage keyed by ComponentID (from Phase 1)                                                                                                                                                                                                                                                                 
- Secondary indexes by ComponentKind and ChainID for efficient queries                                                                                                                                                                                                                                                   
- Type-safe generic accessor functions (RegistryGet, RegistryGetByKind, etc.)                                                                                                                                                                                                                                            
- Thread-safe concurrent access via sync.RWMutex                                                                                                                                                                                                                                                                         
- Registrable interface for self-registering components                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                         
Also adds HasChainID() helper to ComponentID to reduce code duplication.                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                         
This is Phase 2 of the ID type system refactor. The Registry is designed                                                                                                                                                                                                                                                 
to coexist with existing RWMap fields during incremental migration.


Amendments:
* op-devstack: avoid calling range callbacks under lock
@teddyknox teddyknox force-pushed the teddyknox/id-refactor-phase2 branch from aecfdc2 to 82e1be7 Compare February 20, 2026 16:02
@teddyknox teddyknox enabled auto-merge February 20, 2026 16:05
@teddyknox teddyknox added this pull request to the merge queue Feb 20, 2026
Merged via the queue into develop with commit c03b87e Feb 20, 2026
75 checks passed
@teddyknox teddyknox deleted the teddyknox/id-refactor-phase2 branch February 20, 2026 17:04
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