-
Notifications
You must be signed in to change notification settings - Fork 1k
Eliminate AbstractRLPInput abstraction to reduce technical debt #8884
Description
Technical Debt Reduction: AbstractRLPInput/BytesValueRLPInput
Problem
Brittleness Signal: Unnecessary abstraction layer between AbstractRLPInput and BytesValueRLPInput where the abstract class has only one concrete implementation
Root Cause
Hidden Coupling: AbstractRLPInput (607 lines) contains all RLP parsing logic, while BytesValueRLPInput (84 lines) only provides 8 abstract method implementations for byte access
Files Involved:
/ethereum/rlp/src/main/java/org/hyperledger/besu/ethereum/rlp/AbstractRLPInput.java:33/ethereum/rlp/src/main/java/org/hyperledger/besu/ethereum/rlp/BytesValueRLPInput.java:24
Why It Exists: Originally designed to support multiple RLP input sources, but only Bytes-based input was ever implemented
Proposed Solution
Approach: Merge AbstractRLPInput and BytesValueRLPInput into a single concrete BytesValueRLPInput class
Scope:
- Inline all abstract methods from
AbstractRLPInputintoBytesValueRLPInput - Update
RLP.input()factory method - Remove
AbstractRLPInputclass
Success Criteria:
- Single concrete class replaces 2-class hierarchy
- All 84 direct instantiations continue working
- 567 total RLPInput usages unaffected (interface unchanged)
Implementation Plan
Step 1: Merge classes without changing public API
- Copy all concrete methods from
AbstractRLPInputtoBytesValueRLPInput - Inline the 8 abstract method implementations
- Make all previously protected members private
- Run full test suite to verify functionality
Step 2: Update references and clean up
- Update
RLP.input()methods to directly instantiate merged class - Remove
AbstractRLPInput.javafile - Update import statements if needed
- Verify no compilation errors
Safety Checks
- Can revert each step independently
- Tests exist to verify RLP functionality is unchanged (
ethereum/rlptest suite) - No changes to public APIs (
RLPInputinterface remains unchanged) - Change only affects
ethereum/rlpmodule
Blast Radius Assessment
Direct Dependencies: 2 files in ethereum/rlp module only
Hidden Connections: 84 direct instantiations across codebase continue to work via unchanged constructor
Transitive Impact: Zero - RLPInput interface contract preserved
Risk Level: Small (confined to single module, no API changes)
Definition of Done
- Original two-class hierarchy replaced with single class
- All existing tests pass without modification
- Code reviewer confirms abstraction complexity removed
- No functionality changes or new surprise failures
Additional Context
This follows the pattern identified where abstract classes with single implementations indicate over-engineering. The RLP module is mature and stable, making this an ideal candidate for simplification.