Skip to content

Upgrade ethereum-types to 0.16 (drops rand 0.7 chain)#3440

Open
peilun-conflux wants to merge 1 commit intoConflux-Chain:masterfrom
peilun-conflux:cleanup/rand-0.7-ethereum-types
Open

Upgrade ethereum-types to 0.16 (drops rand 0.7 chain)#3440
peilun-conflux wants to merge 1 commit intoConflux-Chain:masterfrom
peilun-conflux:cleanup/rand-0.7-ethereum-types

Conversation

@peilun-conflux
Copy link
Copy Markdown
Contributor

@peilun-conflux peilun-conflux commented Apr 13, 2026

Summary

Bumps the workspace's parity-common stack, removing the ethereum-types → ethbloom → fixed-hash → rand 0.7 transitive chain:

  • ethereum-types 0.9 → 0.16.0
  • rlp 0.4.0 → 0.6
  • keccak-hash 0.5 → 0.12

Stacked on #3439 — merge that first.

Rand 0.7 status after this PR

Eliminated: fixed-hash 0.5/0.6 (via ethereum-types/ethbloom).

Once #3438, #3439, and this PR all land, the only remaining rand 0.7 sources are parity-ws and jsonrpc-pubsub.

Mechanical migrations forced by the bumps

  • uint 0.10: to_big_endian/to_little_endian return [u8; N] now. Rewrote call sites to buf.copy_from_slice(&x.to_big_endian()) or consume the returned array directly.
  • uint 0.10: From<[u8; N]> / From<&[u8]> for U-types removed. U256::from(&bytes)U256::from_big_endian(&bytes).
  • rlp 0.5+: RlpStream::drain() removed; backing buffer became BytesMut. Replaced with .out() (+ .to_vec() where callers return Vec<u8>).
  • rlp 0.5+: RlpStream::out() / rlp::encode() return BytesMut (was Vec<u8>). Added .to_vec() at Vec<u8>-returning boundaries.

Adjacent cleanups

  • Context::transient_storage_at signature: &Vec<u8>&[u8] (matches storage_at).
  • Use the existing cfx_types::u256_to_h256_be helper in gasometer instead of raw H256(x.to_big_endian()).

Follow-ups (not in this PR)

  • Thread BytesMut end-to-end through Message::encode, DatabaseEncodable::db_encode, Block::encode_* — eliminates ~15 .to_vec() copies on network/DB hot paths.
  • Change Context::set_storage / transient_set_storage to take [u8; 32] — eliminates per-SSTORE/TSTORE heap allocation.

🤖 Generated with Claude Code


This change is Reviewable

Bumps the workspace's parity-common stack to current versions:
- ethereum-types 0.9 -> 0.16.0 (uses primitive-types 0.14, fixed-hash 0.8)
- rlp 0.4.0 -> 0.6 (with impl-rlp 0.4)
- keccak-hash 0.5 -> 0.12

Removes the ethereum-types -> ethbloom -> fixed-hash 0.5/0.6 -> rand 0.7
dependency chain entirely. Rand 0.7 still appears transitively via
parity-secp256k1, parity-ws, jsonrpc-pubsub, and cfxkey dev-deps, which
are deferred to follow-up PRs.

Mechanical migrations forced by the bumps:

- uint 0.10 changed `to_big_endian`/`to_little_endian` from writing into
  a caller buffer to returning `[u8; N]`. Call sites rewritten to
  `buf.copy_from_slice(&x.to_big_endian())` or to consume the returned
  array directly.

- uint 0.10 removed `From<[u8; N]>` and `From<&[u8]>` for U-types.
  `U256::from(&bytes)` -> `U256::from_big_endian(&bytes)` everywhere.

- rlp 0.5+ removed `RlpStream::drain()` (the backing buffer became
  `BytesMut`). Replaced with `.out()` plus `.to_vec()` where callers
  return `Vec<u8>`.

- `RlpStream::out()` / `rlp::encode()` now return `BytesMut` instead of
  `Vec<u8>`; added `.to_vec()` at boundaries where the API contract is
  `Vec<u8>`. Threading `BytesMut` end-to-end through `Message::encode`,
  `DatabaseEncodable::db_encode`, and `Block::encode_*` would avoid the
  extra copy on network/DB hot paths and is left as follow-up.

Small adjacent cleanups:
- `Context::transient_storage_at` now takes `&[u8]` (was `&Vec<u8>`)
  to match the sister `storage_at`.
- Use the existing `cfx_types::u256_to_h256_be` helper in gasometer
  instead of the raw `H256(x.to_big_endian())` tuple constructor.

tools/evm-spec-tester tracks the workspace change: `rlp = 0.6` plus the
same uint 0.10 rewrites.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@peilun-conflux
Copy link
Copy Markdown
Contributor Author

duplicate of #3247

@peilun-conflux
Copy link
Copy Markdown
Contributor Author

Fix the issue by following #3254 phased plan.

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