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: optimize setZKPRequests implementation #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yushihang
Copy link

I noticed potential optimization opportunities in the setZKPRequests implementation across verifier contracts. I propose modifying the child contracts to directly call super.setZKPRequests(), considering:

  1. Reuse array length validation from the base class to avoid code duplication
  2. Reduce potential array bounds risks
  3. Improve gas efficiency by avoiding redundant checks

However, this change may affect the original design intent, such as whether child contracts were meant to control their own validation flow. I'd appreciate your confirmation if this approach aligns with the project's design philosophy.

I noticed that EmbeddedZKPVerifier.sol already uses super.setZKPRequests(), while other contracts don't. I'm not sure if this inconsistency was intentional in the original design.

Changes affect:

  • ValidatorWhitelist
  • UniversalVerifier
  • RequestOwnership

Thank you for your review!

- Modify setZKPRequests in ValidatorWhitelist, UniversalVerifier, RequestOwnership and EmbeddedZKPVerifier to use super implementation
- Remove redundant array iteration logic to prevent potential array bounds issues
- Ensure consistent length validation across all verifier contracts
- Improve gas efficiency by avoiding duplicate checks

This change maintains the same functionality while improving security and reducing code duplication.
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.

1 participant