Skip to content

fix(dyn-abi): correct packed encoded size for Function - #1149

Merged
DaniPopes merged 1 commit into
alloy-rs:mainfrom
Ysh204:fix/dyn-abi-function-packed-size
Jul 13, 2026
Merged

DaniPopes merged 1 commit into
alloy-rs:mainfrom
Ysh204:fix/dyn-abi-function-packed-size

Conversation

@Ysh204

@Ysh204 Ysh204 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

DynSolValue::abi_packed_encoded_size() returned 20 bytes for Function values by grouping them with Address, even though Solidity function pointers occupy 24 bytes (20-byte address + 4-byte selector).

This caused two issues:

  1. The initial buffer size for packed encoding was underestimated by 4 bytes per function.
  2. The reported packed encoded size was inconsistent with the actual encoding, which also affects padding calculations performed during packed encoding of arrays of function values.

Solution

  • Return 24 for DynSolValue::Function in abi_packed_encoded_size(), while keeping Address at 20.
  • Add a regression test verifying:
    • Address reports the correct packed encoded size.
    • Function reports the correct packed encoded size.
    • The reported packed encoded size matches the length of abi_encode_packed().
    • Arrays of Function values report the expected packed encoded size and encoded length.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jul 12, 2026
@DaniPopes
DaniPopes merged commit 7dc38ba into alloy-rs:main Jul 13, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants