Skip to content

refactor(trie): remove unused RLP utilities - #21

Merged
SeriousCoding789 merged 2 commits into
SeriousCoding789:clear_rlpfrom
Little-Peony:clean_rlp
Sep 22, 2026
Merged

SeriousCoding789 merged 2 commits into
SeriousCoding789:clear_rlpfrom
Little-Peony:clean_rlp

Conversation

@SeriousCoding789

@SeriousCoding789 SeriousCoding789 commented Sep 3, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Removes the RLP utilities under framework/src/main/java/org/tron/core/capsule/utils that nothing calls, and trims the one file still in use down to what is actually reachable.

RLP is Ethereum's serialization format, inherited from the original ethereumJ fork. TRON serializes transactions, blocks and accounts with protobuf, so RLP has no role in them — a block's txTrieRoot is a plain SHA-256 Merkle tree (BlockCapsule.calcMerkleRootMerkleTree), which never touches RLP.

The one thing RLP is still needed for is accountStateRoot(not activated). That root is produced by org.tron.core.trie.TrieImpl, a Merkle Patricia Trie whose node layout is defined in terms of RLP-encoded lists, so the encoder has to stay to keep that format intact.

  • Deletes six unreferenced files: RLPElement, RLPItem, RLPList, DecodeResult (reachable only from the removed RLP methods), and TxInputUtil / TxOutputUtil (UTXO-era leftovers), plus their four tests.
  • Trims RLP.java from 1216 to 284 lines. TrieImpl uses four entry points; the reachability closure from those keeps six constants, EMPTY_ELEMENT_RLP, both encodeList overloads, decodeLazyList, verifyLength and the nested LList. The other 34 methods go.
  • Drops the duplicate FastByteComparisons. org.tron.common.utils.FastByteComparisons already exists and is what nine other files use; TrieImpl now calls it.

capsule/utils goes from eight files to one. 15 files changed, +52 / −1509.

Why are these changes required?

Most of this code has never had a caller in TRON. Carrying a full second serialization codec, in a package named for capsule utilities, costs review attention on every audit and blurs where the trie's real dependencies begin.

Behaviour: unchanged.

Everything retained is what accountStateRoot depends on, so two properties were verified rather than assumed:

  • All retained members of RLP.java are byte-identical to the previous version. Both encodeList overloads, both decodeLazyList overloads, verifyLength, LList and its five methods, and all six constants were compared against the pre-change file; none was rewritten. The encoder emits the same bytes, so account-state root hashes cannot move.
  • The two FastByteComparisons are the same implementation. equalByte and isEqual are both b1.length == b2.length && compareTo(b1, 0, b1.length, b2, 0, b2.length) == 0, delegating to the same LexicographicalComparerHolder.BEST_COMPARER.

Tests: the four deleted tests covered only deleted classes. TrieTest gains a case for TrieImpl.equals, which is the one changed line the previous revision left uncovered.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: bba9a76a-cc1f-4e61-b57b-c86368eff4a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SeriousCoding789 SeriousCoding789 changed the title refactor(trie): keep only the rlp code the trie uses refactor(trie): remove unused rlp utilities Sep 3, 2026
@SeriousCoding789 SeriousCoding789 changed the title refactor(trie): remove unused rlp utilities refactor(trie): remove unused RLP utilities Sep 3, 2026
@SeriousCoding789
SeriousCoding789 changed the base branch from develop to release_v4.8.3 September 22, 2026 06:08
@SeriousCoding789
SeriousCoding789 changed the base branch from release_v4.8.3 to clear_rlp September 22, 2026 08:03
@SeriousCoding789
SeriousCoding789 merged commit 899ff2c into SeriousCoding789:clear_rlp Sep 22, 2026
17 checks passed
@SeriousCoding789
SeriousCoding789 deleted the clean_rlp branch September 22, 2026 08: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.

2 participants