Skip to content

Eliminate AbstractRLPInput abstraction to reduce technical debt #8884

@jflo

Description

@jflo

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 AbstractRLPInput into BytesValueRLPInput
  • Update RLP.input() factory method
  • Remove AbstractRLPInput class

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 AbstractRLPInput to BytesValueRLPInput
  • 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.java file
  • 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/rlp test suite)
  • No changes to public APIs (RLPInput interface remains unchanged)
  • Change only affects ethereum/rlp module

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.

Metadata

Metadata

Assignees

Labels

P2High (ex: Degrading performance issues, unexpected behavior of core features (DevP2P, syncing, etc))techdebtmaintenance, cleanup, refactoring, documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions