Skip to content

Changes to rlp project to accomodate bytes v2#56

Draft
lu-pinto wants to merge 5 commits intoConsensys:mainfrom
lu-pinto:modify-rlp-project-for-v2
Draft

Changes to rlp project to accomodate bytes v2#56
lu-pinto wants to merge 5 commits intoConsensys:mainfrom
lu-pinto:modify-rlp-project-for-v2

Conversation

@lu-pinto
Copy link
Member

@lu-pinto lu-pinto commented Nov 27, 2025

PR description

Changes to project rlp to accomodate bytes v2.


Note

Introduces v2 implementations for bytes, RLP, and bigints units with comprehensive tests and JMH benchmarks, and adds JMH plugin/configuration to the build.

  • Build:
    • Add conditional me.champeau.jmh plugin with configurable jmh task, async-profiler options, and compiler flags in build.gradle.
    • Add test dependency org.assertj:assertj-core.
    • Add helper CLI arg parsers (_strListCmdArg, _strCmdArg).
  • Bytes v2 (org/apache/tuweni/v2/bytes):
    • New core Bytes API with array/buffer/bytebuf wrappers, concatenation, mutable variant, and utilities.
    • Implementations: ArrayWrappingBytes, BufferWrappingBytes, ByteBufWrappingBytes, ByteBufferWrappingBytes, MutableBytes, ConstantBytesValue, ConcatenatedBytes, DelegatingBytes, Utils.
    • Add benchmarks comparing v1 vs v2 (bytes/src/jmh/...).
  • RLP v2 (org/apache/tuweni/v2/rlp):
    • Reimplement RLP encoding/decoding on top of bytes v2: RLP, RLPReader, RLPWriter, BytesRLPReader/Writer, ByteBufferRLPWriter, AccumulatingRLPWriter, DelegatingRLPWriter.
    • Support list/value ops, bigints, buffers; add tests.
  • Units v2 (org/apache/tuweni/v2/units/bigints):
    • Add unsigned bigints: UInt32, UInt64, UInt256, UInt384 with arithmetic/bitwise ops and utils.
    • Add package metadata and tests.
  • Tests/Adjustments:
    • Extensive new test suites for v2 packages; minor update to existing concatenated bytes test.

Written by Cursor Bugbot for commit 286c7e6. This will update automatically on new commits. Configure here.

This is a collapsed view of the previous old commits:

*   0929d61 Merge remote-tracking branch 'upstream/main' into flatten-Bytes-class-hierarchy
* | 6d79491 Miscelaneous fixes
* | a4def2a Fix memleak in Hash and bug in devp2p Packet creation
* | 10e6e81 fix bug in and/or/xor operations with UInt256/UInt384
* | 578e6bb Move bound checks for Bytes implementation out of constructors
* | b9c6b05 Merge branch 'main' into flatten-Bytes-class-hierarchy
* 4100d8b review feedback
* afba2b9 change megamorphic benchmarks to slice and optimize size()
* b2066fc JMH integration fixes
* e40d796 remove InterfaceCall and VirtualCall benchmarks
* dff599a fix ConnectTwoServersTest - missed package changes and port bindings
* 5aba562 add missing package-info.java files
* 1c641ff fix failure in DefaultDiscoveryV5ServiceTest about reusing ports
* 279acd6 bring in old tuweni v1 after move
* ace7910 move all other touched files to org.apache.tuweni.v2 package
* 65f217b mv org.apache.tuweni.bytes.v2 to org.apache.tuweni.v2.bytes
* ebaa8bd Implement Tuweni v2

Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
This is for easy reviewing by making the PR much shorter.

Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
@lu-pinto lu-pinto marked this pull request as draft November 27, 2025 17:31
@Override
public byte get(int i) {
return this.value;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing bounds check in ConstantBytesValue get method

The get method in ConstantBytesValue returns the constant value without validating that the index i is within bounds. This allows out-of-bounds access without throwing an IndexOutOfBoundsException, violating the contract established by other Bytes implementations like ArrayWrappingBytes which properly validate indices. The method should check that i is between 0 and size() before returning the value.

Fix in Cursor Fix in Web

@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 12, 2025
@github-actions
Copy link

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Dec 26, 2025
@lu-pinto lu-pinto reopened this Jan 7, 2026
@lu-pinto lu-pinto removed the Stale label Jan 7, 2026
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.

1 participant