Repository navigation
refactor(trie): remove unused RLP utilities - #6991
Open
SeriousCoding789 wants to merge 3 commits into
Open
SeriousCoding789 wants to merge 3 commits into
SeriousCoding789 wants to merge 3 commits into
Conversation
refactor(trie): remove unused RLP utilities
SeriousCoding789
requested review from
317787106,
Federico2014 and
halibobo1205
September 22, 2026 08:05
317787106
approved these changes
Sep 23, 2026
Collaborator
|
LGTM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Removes the RLP utilities under
framework/src/main/java/org/tron/core/capsule/utilsthat 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
txTrieRootis a plain SHA-256 Merkle tree (BlockCapsule.calcMerkleRoot→MerkleTree), which never touches RLP.The one thing RLP is still needed for is
accountStateRoot(not activated). That root is produced byorg.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.RLPElement,RLPItem,RLPList,DecodeResult(reachable only from the removedRLPmethods), andTxInputUtil/TxOutputUtil(UTXO-era leftovers), plus their four tests.RLP.javafrom 1216 to 284 lines.TrieImpluses four entry points; the reachability closure from those keeps six constants,EMPTY_ELEMENT_RLP, bothencodeListoverloads,decodeLazyList,verifyLengthand the nestedLList. The other 34 methods go.FastByteComparisons.org.tron.common.utils.FastByteComparisonsalready exists and is what nine other files use;TrieImplnow calls it.capsule/utilsgoes 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
accountStateRootdepends on, so two properties were verified rather than assumed:RLP.javaare byte-identical to the previous version. BothencodeListoverloads, bothdecodeLazyListoverloads,verifyLength,LListand 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.FastByteComparisonsare the same implementation.equalByteandisEqualare bothb1.length == b2.length && compareTo(b1, 0, b1.length, b2, 0, b2.length) == 0, delegating to the sameLexicographicalComparerHolder.BEST_COMPARER.Tests: the four deleted tests covered only deleted classes.
TrieTestgains a case forTrieImpl.equals, which is the one changed line the previous revision left uncovered.