Skip to content

feat: add validated variants to ABI decoding methods #928

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

Merged
merged 7 commits into from
Apr 26, 2025

Conversation

harsh-ps-2003
Copy link
Contributor

@harsh-ps-2003 harsh-ps-2003 commented Apr 16, 2025

Motivation

The fundamental motivation behind these changes is to re-introduce ABI decoding validation that was effectively removed by default in PR #863

This PR removed the validate: bool argument from decoding functions (abi_decode*). The reason was that the existing validation logic was sometimes too strict and incorrectly rejected valid ABI-encoded data found in real-world scenarios. Removing the flag made the default decoding behavior non-validating (or less strict).

However, performing strict ABI validation is still a desirable feature for users who want to ensure data adheres precisely to the expected format, potentially catching encoding errors or unexpected data structures early.

Fixes #927

Solution

So, instead of re-introducing the boolean flag (which complicates the function signatures), the chosen approach was to add separate, parallel methods specifically for validated decoding. These new methods have _validate appended to their names.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@github-project-automation github-project-automation bot moved this to In Progress in Alloy Apr 16, 2025
@harsh-ps-2003 harsh-ps-2003 requested a review from DaniPopes April 18, 2025 09:22
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-project-automation github-project-automation bot moved this from In Progress to Reviewed in Alloy Apr 26, 2025
@DaniPopes DaniPopes enabled auto-merge (squash) April 26, 2025 19:36
@DaniPopes DaniPopes disabled auto-merge April 26, 2025 19:36
@DaniPopes DaniPopes changed the title Add validation methods for ABI decoding across various types feat: add abi_validation methods for ABI decoding across various types Apr 26, 2025
@DaniPopes DaniPopes changed the title feat: add abi_validation methods for ABI decoding across various types feat: add validated variants to ABI decoding methods Apr 26, 2025
@DaniPopes DaniPopes enabled auto-merge (squash) April 26, 2025 19:37
@DaniPopes DaniPopes merged commit 8c7229d into alloy-rs:main Apr 26, 2025
30 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Apr 26, 2025
@harsh-ps-2003 harsh-ps-2003 deleted the validate branch April 28, 2025 06:22
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.

[Feature] Add abi_decode*_validate methods
2 participants