Skip to content

Conversation

@Forostovec
Copy link

Reworked impl_encode in crates/common/rlp/encode.rs to compute the first non-zero byte in a single pass and to encode using direct slices of the original big-endian array. This eliminates the previous double scan and avoids allocating/copying into ArrayVec, which was unnecessary for encoding the integer payload. As a direct consequence, this change also fixes a correctness bug where u128 encoding could panic at runtime due to relying on ArrayVec<[u8; 8]> and attempting to extend it with 16 bytes. The new logic preserves RLP semantics for zero (0x80), single-byte values in the 0x01..=0x7f range (encoded as-is), and multi-byte integers (prefixed with 0x80 + length followed by the trimmed big-endian bytes), aligning with how other parts of the module handle length-prefixed payloads without redundant work.

@Forostovec Forostovec requested a review from a team as a code owner November 23, 2025 13:17
@edg-l
Copy link
Contributor

edg-l commented Nov 24, 2025

There is already a pr open which improves the encoding #5350

@Forostovec
Copy link
Author

There is already a pr open which improves the encoding #5350

Ops, then i will close this

@Forostovec Forostovec closed this Nov 24, 2025
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