Skip to content
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d340a84
docs: add lite mode design document
karlfloersch Sep 30, 2025
dd13439
test: add sync tester test runner script
Oct 1, 2025
65895da
docs: add comprehensive testing section to lite mode design
Oct 1, 2025
a003344
feat(op-node): add lite mode configuration and CLI flags
Oct 1, 2025
93e4375
feat(op-node): disable derivation in lite mode
Oct 1, 2025
ef2604e
feat(op-node): add LiteModeSync component
Oct 1, 2025
b177d39
feat(op-node): integrate LiteModeSync into Driver
Oct 1, 2025
aa52865
fix(op-node): fix compilation errors in lite mode integration
Oct 1, 2025
6ab4d94
docs(lite-mode): update environment variable names in test documentation
Oct 1, 2025
e1ac4b2
feat(devstack): add lite mode support to test infrastructure
Oct 1, 2025
aa9c015
fix(devstack): add missing os import for lite mode support
Oct 1, 2025
d0b113a
fix(lite-mode): handle missing eth_syncing method gracefully
Oct 1, 2025
513f8c2
fix(lite-mode): remove eth_syncing check and fix close panic
Oct 1, 2025
1857f2c
feat(lite-mode): fix unsafe head initialization and complete implemen…
Oct 1, 2025
dfd2e98
refactor(lite-mode): use FindL2Heads for initialization instead of ma…
Oct 1, 2025
4a00e95
feat(lite-mode): add acceptance tests and fix sync issues
Oct 1, 2025
f9210f2
refactor(lite-mode): move derivation disable to SyncStep for clarity
Oct 1, 2025
250276a
refactor(lite-mode): swap order and move catch-up logic to updateFina…
Oct 1, 2025
4554e4d
refactor(lite-mode): simplify safe head sync with backward-walking al…
Oct 1, 2025
96138c3
refactor(lite-mode): address review feedback
Oct 1, 2025
19eb5ac
feat(lite-mode): optimize block verification with header-only fetches
Oct 1, 2025
37a66f1
fix(lite-mode): use event system instead of direct engine calls
Oct 1, 2025
9a8d214
refactor(test): separate lite mode into dedicated test function
Oct 1, 2025
8a3dd82
refactor(lite-mode): extract block hash lookup into helper function
Oct 2, 2025
466b351
refactor(lite-mode): remove redundant warning when block lookup fails
Oct 2, 2025
d4b3556
fix(lite-mode): return error when remote safe is behind local finalized
Oct 2, 2025
cfaf487
refactor(lite-mode): integrate sync into SyncStep instead of separate…
Oct 2, 2025
d53ffc8
fix(lite-mode): use direct engine method calls instead of events and …
Oct 2, 2025
2bf330e
fix(lite-mode): wait for L1 finalization before checking L2 finalized
Oct 2, 2025
064a4c2
perf(lite-mode): prevent CPU starvation of P2P unsafe block processing
Oct 2, 2025
25f08ce
fix(lite-mode): disable challenger in lite mode tests to prevent flakes
Oct 2, 2025
311da5f
fix(lite-mode): prevent duplicate block insertions causing reorgs
Oct 2, 2025
fb9bb40
chore(lite-mode): remove polling logic and unused documentation
Oct 3, 2025
bc73f3a
chore: remove .gitignore from lite_mode tests
Oct 3, 2025
913bbc6
refactor: rename lite mode to tip mode throughout codebase
Oct 3, 2025
ea139b2
fix: correct tip mode environment variable naming
Oct 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
493 changes: 493 additions & 0 deletions LITE_MODE.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions op-acceptance-tests/tests/lite_mode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.test
273 changes: 273 additions & 0 deletions op-acceptance-tests/tests/lite_mode/IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
# Lite Mode Acceptance Test Implementation Summary

This document provides a comprehensive overview of the lite mode acceptance test implementation.

## Overview

The implementation adds proper acceptance testing for lite mode - a new sync mode where op-node sources safe/finalized heads from a remote RPC endpoint instead of deriving them from L1.

## Files Created/Modified

### New Files

1. **`/root/optimism-2/op-acceptance-tests/tests/lite_mode/init_test.go`**
- Test initialization with preset configuration
- Configures test environment with lite mode system

2. **`/root/optimism-2/op-acceptance-tests/tests/lite_mode/lite_mode_test.go`**
- Four comprehensive test cases covering:
- Basic safe head sync
- Finalized head sync
- Unsafe block sync via P2P
- Continuous sync operation

3. **`/root/optimism-2/op-acceptance-tests/tests/lite_mode/README.md`**
- Comprehensive documentation of tests and implementation

4. **`/root/optimism-2/op-devstack/presets/lite_mode.go`**
- Defines `LiteMode` preset structure
- Implements `NewLiteMode()` constructor
- Provides `WithLiteModeSystem()` common option

5. **`/root/optimism-2/op-devstack/sysgo/system_lite_mode.go`**
- Implements `LiteModeSystem()` for creating test infrastructure
- Implements `WithLiteModeOption()` for node configuration
- Uses AfterDeploy hook for dynamic sequencer RPC configuration

### Modified Files

1. **`/root/optimism-2/op-devstack/presets/cl_config.go`**
- Added `WithLiteMode()` preset option
- Configures verifier nodes with lite mode settings

2. **`/root/optimism-2/op-devstack/sysgo/l2_cl.go`**
- Extended `L2CLConfig` struct with:
- `LiteModeEnabled bool`
- `LiteModeRemoteRPC string`

3. **`/root/optimism-2/op-devstack/sysgo/l2_cl_opnode.go`**
- Modified to read lite mode config from `L2CLConfig`
- Maintains backward compatibility with environment variables

## Architecture

### Layered Design

```
┌─────────────────────────────────────────────────────────────┐
│ Acceptance Tests │
│ (lite_mode_test.go - test cases using presets) │
└──────────────────────────┬──────────────────────────────────┘
┌──────────────────────────▼──────────────────────────────────┐
│ Preset Layer │
│ (lite_mode.go - LiteMode struct, NewLiteMode()) │
│ (cl_config.go - WithLiteMode()) │
└──────────────────────────┬──────────────────────────────────┘
┌──────────────────────────▼──────────────────────────────────┐
│ System Layer │
│ (system_lite_mode.go - LiteModeSystem()) │
│ (l2_cl.go - L2CLConfig with lite mode fields) │
└──────────────────────────┬──────────────────────────────────┘
┌──────────────────────────▼──────────────────────────────────┐
│ Node Creation Layer │
│ (l2_cl_opnode.go - OpNode creation with lite mode) │
└─────────────────────────────────────────────────────────────┘
```

### Data Flow

1. **Test Initialization**:
- `TestMain` calls `presets.DoMain()` with `WithLiteModeSystem()`
- System creates orchestrator and initializes infrastructure

2. **System Setup**:
- `LiteModeSystem()` creates minimal system with sequencer
- AfterDeploy hook retrieves sequencer RPC endpoint
- Verifier CL node created with lite mode configuration

3. **Test Execution**:
- Tests use DSL to interact with nodes
- Verify sync behavior at different safety levels
- Check P2P connectivity and block propagation

## Key Design Decisions

### 1. Dynamic RPC Configuration

**Problem**: The verifier needs the sequencer's RPC endpoint, but the sequencer is created dynamically.

**Solution**: Use `stack.AfterDeploy()` hook to:
- Wait for sequencer creation
- Retrieve sequencer's RPC endpoint
- Configure verifier with this endpoint

```go
opt.Add(stack.AfterDeploy(func(orch *Orchestrator) {
sequencerCL, ok := orch.l2CLs.Get(ids.L2CL)
sequencerRPC := sequencerCL.UserRPC()
// Create verifier with sequencer RPC
stack.ApplyOptionLifecycle(WithL2CLNode(ids.L2CLB, ids.L1CL, ids.L1EL, ids.L2ELB,
WithLiteModeOption(sequencerRPC)), orch)
}))
```

### 2. Configuration Extension

**Problem**: Need to configure lite mode without breaking existing code.

**Solution**: Extend `L2CLConfig` with new fields:
- Maintains backward compatibility
- Allows both programmatic and environment-based configuration
- Clean separation of concerns

```go
type L2CLConfig struct {
// Existing fields...

// New lite mode fields
LiteModeEnabled bool
LiteModeRemoteRPC string
}
```

### 3. P2P Connectivity

**Problem**: Lite mode disables derivation but should still receive unsafe blocks.

**Solution**: Maintain P2P connections:
- Lite mode only affects safe/finalized sync
- Unsafe blocks still propagate via P2P gossip
- Tests verify this dual-mode operation

### 4. Test Coverage

**Problem**: Need comprehensive testing of lite mode behavior.

**Solution**: Four focused test cases:
- **Basic sync**: Core functionality
- **Finalized sync**: Finalization behavior
- **P2P unsafe**: Ensure gossip works
- **Continuous sync**: Long-running stability

## Testing Strategy

### Test Hierarchy

1. **Unit Level** (in op-node):
- Core lite mode sync logic
- Individual component behavior

2. **Integration Level** (these acceptance tests):
- Multi-node interaction
- End-to-end sync verification
- P2P and derivation interaction

3. **System Level** (future):
- Performance benchmarks
- Failure recovery
- Production scenarios

### Verification Points

Each test verifies:
- ✅ Block number progression
- ✅ Hash consistency
- ✅ P2P connectivity
- ✅ Sync status at all safety levels

## Usage Examples

### Running Tests

```bash
# All lite mode tests
go test ./op-acceptance-tests/tests/lite_mode/...

# Specific test with verbose output
go test ./op-acceptance-tests/tests/lite_mode/ -run TestLiteModeBasicSync -v

# With additional logging
go test ./op-acceptance-tests/tests/lite_mode/... -v -test.timeout=10m
```

### Using Lite Mode in Other Tests

```go
func TestMain(m *testing.M) {
presets.DoMain(m,
presets.WithLiteModeSystem(),
presets.WithConsensusLayerSync(),
)
}

func TestMyFeature(gt *testing.T) {
t := devtest.SerialT(gt)
sys := presets.NewLiteMode(t)

// sys.L2CL is the sequencer (full derivation)
// sys.L2CLB is the verifier (lite mode)

// Your test code here...
}
```

### Manual Configuration (if needed)

```go
// Configure a specific node with lite mode
WithL2CLNode(nodeID, l1CL, l1EL, l2EL,
presets.WithLiteMode("http://sequencer:8545"))
```

## Validation

The implementation has been validated for:
- ✅ Code compilation (all packages)
- ✅ Proper imports and dependencies
- ✅ Consistent with existing test patterns
- ✅ Proper use of devstack framework
- ✅ DSL usage for test operations

## Future Work

### Potential Enhancements

1. **Advanced Test Scenarios**:
- Chain reorganization handling
- Network partition recovery
- RPC endpoint failover
- Multiple lite mode verifiers

2. **Performance Testing**:
- Sync speed comparisons
- Resource usage metrics
- Scalability testing

3. **Integration Tests**:
- Mix of lite mode and full nodes
- Cross-chain lite mode (interop)
- Lite mode with different sync modes

4. **Tooling**:
- Helper functions for common patterns
- Debug utilities for lite mode
- Monitoring/metrics collection

## Conclusion

This implementation provides:
- ✅ Comprehensive acceptance testing for lite mode
- ✅ Clean, maintainable code following existing patterns
- ✅ Proper abstraction layers (preset → system → node)
- ✅ Backward compatibility with environment variables
- ✅ Extensible framework for future enhancements
- ✅ Clear documentation and examples

The design prioritizes:
- **Testability**: Easy to write new test cases
- **Maintainability**: Clear structure and documentation
- **Extensibility**: Easy to add new features
- **Reliability**: Comprehensive test coverage
Loading