Skip to content

Conversation

@ep0chzer0
Copy link

Summary

Fixes #1203

Adds enum range information to the echidna printer output to help Echidna generate valid calldata for enum parameters. Since enums are converted to uint256 in the ABI, Echidna needs to know the valid range to avoid producing invalid calldata.

Changes

  • Added _extract_enum_ranges() function that extracts enum definitions from contracts
  • Added enum_ranges field to the echidna printer JSON output

Example Output

{
  "enum_ranges": {
    "MyContract": {
      "Status": 4,
      "Priority": 3
    }
  }
}

This indicates:

  • Status enum has 4 valid values (0, 1, 2, 3)
  • Priority enum has 3 valid values (0, 1, 2)

Test Plan

  • Verify enum extraction works for contracts with enums
  • Verify output format matches expected JSON structure
  • Run black formatter

🤖 Generated with Claude Code

@ep0chzer0 ep0chzer0 requested a review from smonicas as a code owner January 16, 2026 11:40
@ep0chzer0
Copy link
Author

Hello maintainers! This adds enum range information to the echidna printer as requested in #1203. The implementation follows the format suggested in the issue. Could you please approve the CI workflows to run? Thank you!

@ep0chzer0 ep0chzer0 force-pushed the feature/echidna-enum-ranges branch 2 times, most recently from 5bf4647 to 6f2452a Compare January 16, 2026 13:35
Export enum definitions and their valid ranges to help Echidna
generate valid calldata for enum parameters. Since enums are
converted to uint256 in the ABI, Echidna needs to know the valid
range to avoid producing invalid calldata.

Example output:
```json
{
  "enum_ranges": {
    "MyContract": {
      "Status": 4
    }
  }
}
```

This indicates Status enum has 4 valid values (0, 1, 2, 3).

Fixes crytic#1203
@ep0chzer0 ep0chzer0 force-pushed the feature/echidna-enum-ranges branch from 6f2452a to aa1dc0c Compare January 16, 2026 23:27
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.

add enum size in echidna printer export

1 participant