Skip to content

Changes to io project to accomodate bytes v2#53

Draft
lu-pinto wants to merge 4 commits intoConsensys:mainfrom
lu-pinto:modify-io-project-for-v2
Draft

Changes to io project to accomodate bytes v2#53
lu-pinto wants to merge 4 commits intoConsensys:mainfrom
lu-pinto:modify-io-project-for-v2

Conversation

@lu-pinto
Copy link
Member

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

PR description

Changes to project io to accomodate bytes v2.

NOTE: this PR has a dependency on #40 and amount of files changed will decrease once that PR goes in.


Note

Introduce v2 bytes library and io codecs, add JMH benchmarks, and enable JMH in build.

  • Bytes v2:
    • Add new org.apache.tuweni.v2.bytes API (Bytes, MutableBytes, Bytes32, Bytes48, wrappers for ByteBuffer/ByteBuf/Buffer, ConcatenatedBytes, etc.).
    • Comprehensive unit tests for core operations and utilities.
  • IO v2:
    • Add org.apache.tuweni.v2.io codecs: Base32, Base58(+Base58Codec), Base64, Base64URLSafe using v2 Bytes.
    • Corresponding unit tests.
  • Benchmarks:
    • Add JMH benchmarks comparing v1 vs v2 bytes slicing (bytes/src/jmh/...).
  • Build:
    • Enable JMH plugin/configuration when src/jmh exists; add async-profiler options and annotation processor.
    • Add assertj-core for tests.

Written by Cursor Bugbot for commit 2d27030. 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>
@Override
public void appendTo(ByteBuffer byteBuffer) {
byteBuffer.put(this.byteBuffer);
}
Copy link

Choose a reason for hiding this comment

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

Bug: appendTo(ByteBuffer) ignores offset in ByteBufferWrappingBytes

The appendTo(ByteBuffer) method ignores the offset field entirely. Unlike BufferWrappingBytes and ByteBufWrappingBytes which pre-slice their underlying buffers in the constructor, ByteBufferWrappingBytes stores the offset separately and must use it in all operations. Every other method in this class (get, getInt, getLong, slice, mutableCopy, toArray, and, or, xor, equals, computeHashcode) correctly uses this.offset, but appendTo just calls byteBuffer.put(this.byteBuffer) which will transfer bytes from the wrong position when the instance was created with a non-zero offset.

Fix in Cursor Fix in Web

@lu-pinto lu-pinto marked this pull request as draft November 27, 2025 17:22
@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