Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sol-types): many ABI coder fixes #434

Merged
merged 4 commits into from
Nov 23, 2023
Merged

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Nov 23, 2023

Motivation

While writing tests for #433, I found that word calculation was off, so I found all these separate bugs relating to size calculation.

  • rename SolCall::Arguments to Parameters
  • fix fixed-length arrays and tuple decoding
  • fix String and Bytes encoded size calculation
    • before: 32 + self.len().next_multiple_of(32), this returns 0 -> 64, 1 -> 64; when it should be 0 -> 64; 1 -> 92, so it was a word off most of the time.
  • fix array encoded size calculations
    • I really don't know what happened here. These should be identical to self.tokenize().total_words() * 32
  • fix token word count calculations for arrays and tuples
    • dynamic should be 1 (offset) + elements.total_words(), while it was 1 + N
    • non-dynamic should be just elements.total_words(), while it was elements.head_words()
  • fixed-size arrays and tuples should be treated identically
  • most length tests were just wrong because of everything listed above, and were adapted to make them pass (by using either the wrong encoded array or wrapping in single-element tuple which doesn't really make sense)

cc @prestwich (:

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@DaniPopes DaniPopes marked this pull request as ready for review November 23, 2023 18:18
@DaniPopes DaniPopes changed the title Dani/abi fixed array decoding fix(sol-types): many ABI codec fixes Nov 23, 2023
@DaniPopes DaniPopes changed the title fix(sol-types): many ABI codec fixes fix(sol-types): many ABI coder fixes Nov 23, 2023
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@DaniPopes DaniPopes merged commit ac5af6b into main Nov 23, 2023
20 checks passed
@DaniPopes DaniPopes deleted the dani/abi-fixed-array-decoding branch November 23, 2023 21:42
@phil-ociraptor
Copy link

Woot! Was running into a confounding calldata ABI encoding issue regarding arrays in alloy 0.4.0 and I think 0.5.0 (and presumably this PR) fixes it! ty for the fix (whether here or elsewhere)

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.

[Bug] abi_decode panic when using sol types of fixed bytes
3 participants