Skip to content

# Maintainability Cleanup#10

Merged
feliam merged 1 commit intomainfrom
dev/maintainability-cleanup
Mar 1, 2026
Merged

# Maintainability Cleanup#10
feliam merged 1 commit intomainfrom
dev/maintainability-cleanup

Conversation

@feliam
Copy link
Collaborator

@feliam feliam commented Mar 1, 2026

Comprehensive refactor focused on readability, reduced boilerplate, and dependency freshness.

Changes

Core Refactor

  • opcodes.rs — Collapsed from 215 → 18 lines. Removed all 10 opcode struct/impl pairs; encoding logic moved inline into the Action enum in flow_builder.rs. Only the 12 opcode byte constants remain.

  • flow_builder.rs — Major cleanup:

    • Action enum now uses struct variants directly (no separate opcode structs)
    • build() / build_raw() take &self instead of &mut self — they never mutated state
    • Peephole optimizer rewritten from O(n²) reverse-remove to O(n) retain
    • Hardcoded executeActions() selector replaced with a named EXECUTE_ACTIONS_SELECTOR constant (documented, verified by a unit test)
    • Fixed off-by-one: data.len() < u16::MAXdata.len() <= u16::MAX as usize

Dependency Upgrade

  • alloy dev-dependency upgraded from 1.2.11.7
  • tokio dev-dependency relaxed from 1.441
  • No new runtime dependencies added

Test Cleanup & Migration

  • Renamed ONEHUNDRED_ETHTEN_ETH (value was 10e18, not 100e18)
  • Fixed ~8 "shoud shave" typos, removed "?? ?AHHH" debug comments
  • Corrected misleading assertion comments throughout
  • Migrated to alloy 1.7 API:
    • on_anvil()connect_anvil(), on_anvil_with_config()connect_anvil_with_config()
    • Removed complex AnvilTestProvider type alias → impl Provider + AnvilApi<Ethereum>
    • Simplified imports (removed FillProvider, JoinFill, Identity, etc.)

New Tests

Test Purpose
test_execute_actions_selector Guards against selector drift — asserts the hardcoded bytes match keccak256("executeActions()")
test_flow_builder_max_data_length Regression guard for the off-by-one fix — verifies u16::MAX byte payloads are accepted

Documentation

  • README.md — Fixed example: ONEHUNDRED_ETHHUNDRED_ETH, removed unused Bytes import, corrected crate name multiplexermultiplexer_evm
  • CONTRIBUTING.md — Fixed title "Executor Contract" → "Multiplexer", fixed placeholder GitHub URLs → BitFinding/multiplexer

Verification

cargo +stable test test_flow_builder test_execute_actions -- --nocapture

running 7 tests
test test::test_flow_builder_call ... ok
test test::test_flow_builder_delegatecall ... ok
test test::test_flow_builder_create ... ok
test test::test_flow_builder_combined_operations ... ok
test test::test_flow_builder_max_data_length ... ok
test test::test_execute_actions_selector ... ok

test result: ok. 7 passed; 0 failed

Fork tests (ETH_RPC_URL=<url> cargo +stable test) not run in this PR — they require a mainnet RPC endpoint.

Stats

6 files changed, 457 insertions(+), 475 deletions(-)

- Collapse opcodes.rs from 215 to 18 lines (remove struct boilerplate)
- Refactor FlowBuilder: Action enum with struct variants, inline encoding
- build()/build_raw() now take &self instead of &mut self
- Peephole optimizer: O(n) retain instead of O(n²) reverse-remove
- Replace hardcoded selector with documented EXECUTE_ACTIONS_SELECTOR const
- Fix off-by-one assert in call() (< u16::MAX -> <= u16::MAX)
- Upgrade alloy dev-dep 1.2.1 -> 1.7, migrate test API accordingly
- Rename ONEHUNDRED_ETH -> TEN_ETH (value was 10e18, not 100e18)
- Fix typos and remove debug comments in tests
- Add test_execute_actions_selector (selector drift guard)
- Add test_flow_builder_max_data_length (off-by-one regression guard)
- Fix CONTRIBUTING.md placeholder URLs
@feliam feliam requested a review from snf March 1, 2026 17:50
@feliam feliam merged commit df8cb69 into main Mar 1, 2026
1 check passed
@feliam feliam deleted the dev/maintainability-cleanup branch March 1, 2026 19:31
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