Skip to content

test: Compute the RLP length prefix in a 64-bit word - #1811

Draft
chfast wants to merge 2 commits into
masterfrom
rlp-length-prefix
Draft

chfast wants to merge 2 commits into
masterfrom
rlp-length-prefix

Conversation

@chfast

@chfast chfast commented Nov 7, 2026

Copy link
Copy Markdown
Member

Compute the RLP length prefix (the base byte and up to 7 big-endian
length bytes) left-aligned in a 64-bit word. This raises the length
limit to 2^56-1 bytes. Then build the encoding in a single string:
store the prefix word with a single 8-byte store, shrink the string to
the prefix length and append the payload into the reserved space. This
replaces concatenating a separate prefix string with the payload,
which cost an extra string construction and copy.

Stacked on #1807 (the first commit).

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (6fb712f) to head (ebcd98b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1811   +/-   ##
=======================================
  Coverage   98.23%   98.23%           
=======================================
  Files         186      186           
  Lines       17192    17254   +62     
  Branches     3963     3997   +34     
=======================================
+ Hits        16888    16950   +62     
  Misses        235      235           
  Partials       69       69           
Flag Coverage Δ
eest-develop-gmp 26.68% <22.66%> (-0.07%) ⬇️
eest-legacy 17.18% <22.66%> (-0.04%) ⬇️
eest-libsecp256k1 28.64% <22.66%> (-0.08%) ⬇️
eest-stable 83.75% <100.00%> (+0.01%) ⬆️
evmone-unittests 93.96% <100.00%> (+0.02%) ⬆️
riscv64 94.83% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 96.60% <ø> (ø)
tooling 94.88% <100.00%> (+0.01%) ⬆️
tests 99.80% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
test/unittests/state_rlp_test.cpp 100.00% <100.00%> (ø)
test/utils/rlp.hpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 15 benchmarks

1 warning

⚠️ 216 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 201 improved benchmarks
❌ 15 regressed benchmarks
✅ 683 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH24-benchmark-gas-value_1M] 48.6 ms 54.7 ms -11.13%
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH26-benchmark-gas-value_1M] 52.7 ms 59.2 ms -11.08%
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH25-benchmark-gas-value_1M] 51.1 ms 57.4 ms -11%
❌ test_push[fork_Osaka-blockchain_test-opcode_PUSH23-benchmark-gas-value_1M] 47.4 ms 53.2 ms -11%
❌ baseline/analyse/main/structarray_alloc 5.3 µs 5.4 µs -2.05%
❌ test_gas_op[fork_Osaka-blockchain_test-benchmark-gas-value_1M] 12 ms 12.2 ms -2.01%
❌ test_dup[fork_Osaka-blockchain_test-opcode_DUP14-benchmark-gas-value_1M] 9.4 ms 9.5 ms -1.89%
❌ test_dup[fork_Osaka-blockchain_test-opcode_DUP13-benchmark-gas-value_1M] 9.3 ms 9.5 ms -1.7%
❌ test_dup[fork_Osaka-blockchain_test-opcode_DUP4-benchmark-gas-value_1M] 9.4 ms 9.5 ms -1.69%
❌ test_calldatasize[fork_Osaka-blockchain_test-zero_data_True-calldata_size_0-benchmark-gas-value_1M] 14 ms 14.3 ms -1.59%
❌ test_dup[fork_Osaka-blockchain_test-opcode_DUP15-benchmark-gas-value_1M] 9.4 ms 9.5 ms -1.58%
❌ test_msize[fork_Osaka-blockchain_test-mem_size_1000-benchmark-gas-value_1M] 12.9 ms 13.1 ms -1.54%
❌ test_calldatasize[fork_Osaka-blockchain_test-zero_data_False-calldata_size_256-benchmark-gas-value_1M] 14.1 ms 14.3 ms -1.28%
❌ test_dup[fork_Osaka-blockchain_test-opcode_DUP2-benchmark-gas-value_1M] 9.4 ms 9.6 ms -1.23%
❌ baseline/analyse/main/sha1_shifts 10.9 µs 11 µs -1.01%
⚡ test_block_full_data[fork_Osaka-blockchain_test-zero_byte_True-benchmark-gas-value_1M] 14.3 ms 12.6 ms +12.94%
⚡ test_block_full_data[fork_Osaka-blockchain_test-zero_byte_False-benchmark-gas-value_1M] 4.6 ms 4.1 ms +11.78%
⚡ test_bls12_381[fork_Osaka-blockchain_test-bls12_g2msm-benchmark-gas-value_1M] 4.7 ms 4.4 ms +8.27%
⚡ test_bls12_g1_msm[fork_Osaka-blockchain_test-k_128-benchmark-gas-value_1M] 5 ms 4.6 ms +8.23%
⚡ test_bls12_381[fork_Osaka-blockchain_test-bls12_g1msm-benchmark-gas-value_1M] 5.1 ms 4.7 ms +8.05%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rlp-length-prefix (ebcd98b) with master (6fb712f)

Open in CodSpeed

The RLP encoder wrote at most 3 length bytes and asserted that the
payload is at most 0xffffff bytes. Encoding a longer list, e.g. the
block access list of a block with a large gas limit in
BlockAccessList::hash(), aborted in debug builds and produced a wrong
prefix with NDEBUG.

Add the 4-byte length case. This raises the limit to 4 GiB.
Compute the RLP length prefix (the base byte and up to 7 big-endian
length bytes) left-aligned in a 64-bit word. This raises the length
limit to 2^56-1 bytes. Then build the encoding in a single string:
store the prefix word with a single 8-byte store, shrink the string to
the prefix length and append the payload into the reserved space. This
replaces concatenating a separate prefix string with the payload,
which cost an extra string construction and copy.

This branch has not been deployed

No deployments
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