Skip to content

feat: introduce lightweighted multicall for the same target#79

Open
krboktv wants to merge 9 commits into
masterfrom
feat/new-multicall
Open

feat: introduce lightweighted multicall for the same target#79
krboktv wants to merge 9 commits into
masterfrom
feat/new-multicall

Conversation

@krboktv

@krboktv krboktv commented Feb 21, 2026

Copy link
Copy Markdown
Member

Change Summary

What does this PR change?

  • multicallOneTargetPacked(): Single-target multicall; returns one packed word per call (success, outOfRange, gasUsed, value).
  • multicallOneTargetPackedPatchable(): Single-target multicall with patchable calldata: each entry has one base calldata and several patch values applied at an offset, so one base can drive many calls.

Testing & Verification

How was this tested?

  • Unit tests
  • Integration tests
  • Manual testing (describe steps)
  • Verified on staging

Risk Assessment

Risk Level:

  • Low - Minor changes, no operational impact
  • Medium - Moderate changes, limited impact, standard rollback available
  • High - Significant changes, potential operational impact, complex rollback

Risks & Impact

  • Negative results are not allowed
  • The return value should be <= 226bits

@krboktv krboktv marked this pull request as ready for review February 24, 2026 13:11
@galekseev galekseev requested a review from Copilot February 25, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown

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 introduces two new lightweight multicall functions optimized for single-target batch calls with packed return values. The changes add gas-efficient alternatives to the existing multicall functions by encoding results into packed 256-bit words containing success status, out-of-range flags, gas usage, and return values.

Changes:

  • Adds multicallOneTargetPacked() for batching multiple calls to the same target with compact result encoding
  • Adds multicallOneTargetPackedPatchable() for efficient batching where one base calldata can be reused with different patch values
  • Includes comprehensive test suite with JavaScript encoding/decoding helpers

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
contracts/MultiCall.sol Adds two new multicall functions implemented in Yul assembly for gas efficiency
contracts/mocks/MultiCallTestTarget.sol Test target contract providing functions for testing the new multicall implementations
test/multicall/utils.js Utility functions for hex/bytes conversion used by test helpers
test/multicall/one-target-multicall.js JavaScript helper classes for encoding/decoding multicallOneTargetPacked calls
test/multicall/patchable-multicall.js JavaScript helper classes for encoding/decoding multicallOneTargetPackedPatchable calls
test/multicall/MultiCall.js Comprehensive test suite covering both new multicall functions and existing multicallWithGas
test/EvmHelpers.js Removed placeholder test file

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

Comment thread contracts/MultiCall.sol
Comment thread contracts/MultiCall.sol
Comment thread contracts/MultiCall.sol
Comment thread contracts/MultiCall.sol
Comment thread contracts/MultiCall.sol Outdated
Comment thread contracts/MultiCall.sol
Comment thread contracts/mocks/MultiCallTestTarget.sol Outdated
Comment thread contracts/mocks/MultiCallTestTarget.sol Outdated
Comment thread test/multicall/MultiCall.js Outdated
Comment thread contracts/MultiCall.sol Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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