Skip to content

Support Empty Array in Constructor Arguments#69

Merged
stiefn merged 1 commit intomainfrom
empty_constructor_array
Jul 3, 2025
Merged

Support Empty Array in Constructor Arguments#69
stiefn merged 1 commit intomainfrom
empty_constructor_array

Conversation

@ritzdorf
Copy link
Contributor

Currently the code fails when there is an empty array passed as a constructor argument because it cannot figure out the type during the decoding.

Now we remember the type given by the ABI.

Long-term we should probably generally check that ABI types and decoded types match.

@ritzdorf ritzdorf requested a review from Copilot May 21, 2025 15:38
Copy link

Copilot AI left a comment

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 adds support for empty array constructor arguments by preserving ABI type information and improves error reporting when build-info files are missing.

  • Include the contract name in the “no build-info” error message
  • Populate a backup type_string for constructor args from the ABI
  • Handle empty arrays by retaining the ABI type and setting the value to 0x

Reviewed Changes

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

File Description
lib/bytecode_verification/parse_json.rs Enhanced error message; initialized type_string from ABI selector
lib/bytecode_verification/compare_bytecodes.rs Switched println to debug log; added handling for empty-array values
Comments suppressed due to low confidence (2)

lib/bytecode_verification/parse_json.rs:1446

  • The format! call uses a named placeholder {contract_name} without providing a named argument. Change this to use a positional placeholder, e.g., format!("No build-info files for {} could be found.", contract_name).
format!("No build-info files for {contract_name} could be found.")

lib/bytecode_verification/compare_bytecodes.rs:300

  • No tests cover the empty-array constructor argument path. Add unit tests to verify that empty arrays are handled correctly and that arg.value and arg.type_string are set as expected.
if encoded_value.len() == 0 {

@stiefn stiefn force-pushed the empty_constructor_array branch from 906c213 to a50a813 Compare July 3, 2025 10:53
@stiefn stiefn force-pushed the empty_constructor_array branch from a50a813 to 661d944 Compare July 3, 2025 10:55
@stiefn stiefn merged commit fb2ef6b into main Jul 3, 2025
1 check passed
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.

3 participants