Skip to content

Bletner/intx be load store removal#2122

Draft
brett-monad wants to merge 2 commits intomainfrom
bletner/intx_be_load_store_removal
Draft

Bletner/intx be load store removal#2122
brett-monad wants to merge 2 commits intomainfrom
bletner/intx_be_load_store_removal

Conversation

@brett-monad
Copy link
Contributor

No description provided.

…tions

- Add monad::to_big_endian in int.hpp as two overloads with explicit
  requires clauses: one for std::unsigned_integral (uses std::byteswap),
  one for intx multi-word types (uses word reversal with value
  initialization to avoid uninitialized padding bytes); remove
  using ::intx::to_big_endian
- Add static_assert documenting little-endian platform assumption
- Replace all intx::to_big_endian call sites with monad::to_big_endian
- Replace intx::as_bytes() with direct field access (.bytes), plain &x
  for memcpy sources, or unsigned char const* casts for read-only views;
  use unsigned char* for write destinations
- Fix strict aliasing UB in receipt.cpp set_3_bits by using memcpy
  instead of reinterpret_cast<uint16_t*> on uint8_t[]
- Fix transitive includes: add direct includes for int.hpp, bytes.hpp,
  <cstring> where needed; remove intx/intx.hpp from receipt.cpp and
  execute_block.cpp
- Assert std::has_unique_object_representations_v<T> in decode_raw_num
  to make the no-padding/stable-layout assumption explicit
- Add tests for monad::to_big_endian covering uint8/16/32/64/128/256/512,
  idempotency, and zero

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@brett-monad brett-monad force-pushed the bletner/intx_be_load_store_removal branch 2 times, most recently from 091cffa to e36874a Compare March 6, 2026 20:03
@brett-monad brett-monad marked this pull request as ready for review March 6, 2026 20:03
Copilot AI review requested due to automatic review settings March 6, 2026 20:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes big-endian load/store and endian-swap operations across the codebase by replacing direct intx::be::* and related usage with monad::be_load, monad::be_store, and monad::to_big_endian from category/core/int.hpp.

Changes:

  • Introduces monad::to_big_endian, monad::be_load, and monad::be_store helpers in category/core/int.hpp.
  • Replaces intx::be::{load,store} / intx::to_big_endian / intx::as_bytes usage across execution, RPC, VM, tests, and fuzzers.
  • Adds unit tests covering monad::to_big_endian behavior and wires them into the core test CMake target.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
category/vm/llvm/emitter.hpp Switches tx gas price decoding to monad::be_load.
category/rpc/overrides.cpp Replaces override balance/base-fee loads with monad::be_load and removes direct intx include.
category/rpc/monad_executor_test.cpp Updates test big-endian stores/encodes to monad::be_store/monad::to_big_endian.
category/execution/monad/staking/util/val_execution.cpp Uses monad::be_load for storage key decoding.
category/execution/monad/staking/util/delegator.cpp Uses monad::be_load for storage key decoding.
category/execution/monad/staking/util/consensus_view.cpp Uses monad::be_load for key decoding and includes new helper header.
category/execution/monad/staking/test_staking_contract.cpp Updates msg.value encoding to monad::be_store.
category/execution/monad/staking/test_read_valset.cpp Uses monad::be_load for stake decoding.
category/execution/monad/staking/test/input_generation.cpp Uses monad::be_store for stake encoding in signed messages.
category/execution/monad/staking/staking_contract.cpp Replaces calldata selector/value decoding with monad::be_load.
category/execution/monad/staking/fuzzer/staking_contract_model.cpp Replaces value decoding with monad::be_load.
category/execution/monad/staking/fuzzer/staking_contract_machine.cpp Replaces load/store usage with monad helpers; removes remaining intx::as_bytes usage in address generation.
category/execution/monad/reserve_balance/reserve_balance_contract_test.cpp Removes intx byte access; uses monad::to_big_endian/to_bytes to emit PUSH immediates.
category/execution/monad/reserve_balance/reserve_balance_contract.cpp Replaces selector decoding with monad::be_load.
category/execution/monad/execute_system_transaction.cpp Uses monad::be_store for message value and monad::be_load for selector decode.
category/execution/monad/chain/monad_devnet.cpp Uses monad::be_store for nonce encoding.
category/execution/ethereum/tx_context.cpp Replaces to_big_endian calls with monad::to_big_endian.
category/execution/ethereum/trace/call_tracer.cpp Uses monad::be_load for msg.value decoding.
category/execution/ethereum/rlp/encode2.hpp Switches integer endian conversion to monad::to_big_endian and adjusts pointer constness.
category/execution/ethereum/rlp/decode.hpp Replaces intx byte access and conversion with memcpy + monad::to_big_endian.
category/execution/ethereum/precompiles_impl.cpp Replaces intx byte access and conversion with reinterpret_cast + monad::to_big_endian.
category/execution/ethereum/precompiles_bls12.cpp Switches big-endian load to monad::be_load<uint512_t>.
category/execution/ethereum/execute_transaction_test.cpp Updates test big-endian store to monad::be_store.
category/execution/ethereum/execute_transaction.cpp Uses monad::be_load/monad::be_store for tx context chain_id and message value encoding.
category/execution/ethereum/execute_block.cpp Switches beacon root slot/key encoding to monad::to_big_endian.
category/execution/ethereum/evmc_host_test.cpp Updates tx context encoding to monad::be_store.
category/execution/ethereum/evmc_host.cpp Uses monad::be_store to encode balance into evmc::uint256be.
category/execution/ethereum/evm_test.cpp Updates message value encoding to monad::be_store.
category/execution/ethereum/evm.cpp Uses monad::be_load for msg.value decoding in balance/transfer logic.
category/execution/ethereum/core/transaction.cpp Uses monad::be_store for signature serialization.
category/execution/ethereum/core/receipt.cpp Replaces aliasing-based hash word reads with memcpy + monad::to_big_endian.
category/execution/ethereum/core/contract/storage_variable.hpp Uses monad::be_load/monad::be_store for storage slot key conversions.
category/execution/ethereum/core/contract/storage_array.hpp Uses monad::be_load/monad::be_store for array index slot computations.
category/execution/ethereum/chain/ethereum_mainnet.cpp Uses monad::be_store for nonce encoding.
category/execution/ethereum/block_hash_history_test.cpp Switches test encoding to monad::to_big_endian.
category/execution/ethereum/block_hash_history.cpp Switches slot key encoding to monad::to_big_endian.
category/core/test/to_big_endian_test.cpp Adds unit tests for monad::to_big_endian across integer widths.
category/core/test/CMakeLists.txt Registers the new to_big_endian_test.
category/core/int.hpp Adds monad::to_big_endian, monad::be_load, and monad::be_store helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Adds monad::be_load, monad::be_store, and monad::to_big_endian to
category/core/int.hpp, replacing intx::be::load, intx::be::store, and
intx::to_big_endian across the codebase.

Also adds missing direct includes to int.hpp and decode.hpp that were
previously satisfied transitively.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brett-monad brett-monad force-pushed the bletner/intx_be_load_store_removal branch from e36874a to f37461c Compare March 6, 2026 20:36
@brett-monad brett-monad requested a review from Copilot March 6, 2026 20:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 39 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brett-monad brett-monad marked this pull request as draft March 11, 2026 17:39
@brett-monad brett-monad marked this pull request as draft March 11, 2026 17:39
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