-
Notifications
You must be signed in to change notification settings - Fork 44
Refactor state handling and enhance caching in EthStateStorage #382
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
Conversation
…eStorage - Removed unnecessary checks for genesis state in PubSignalsVerifier. - Enhanced error handling in EthStateStorage to cache genesis state correctly. - Updated StateInfo interface to enforce id as a required field. - Introduced getIsGenesisStateById utility function for better clarity. - Added tests for EthStateStorage to ensure proper caching behavior for genesis states.
There was a problem hiding this 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 refactors state handling in the Polygon ID SDK to streamline genesis state verification and improve caching behavior. The main changes move genesis state validation logic from PubSignalsVerifier into EthStateStorage, consolidate duplicate code into a utility function, and enforce stricter type requirements.
Key Changes
- Extracted
getIsGenesisStateByIdutility function to eliminate code duplication and improve maintainability - Enhanced
EthStateStorage.getStateInfoByIdAndStateto handle genesis states that don't exist in the smart contract by verifying if the state is a valid genesis state - Simplified
PubSignalsVerifier.resolveby delegating genesis state logic to the storage layer - Made
StateInfo.ida required field (was optional) to improve type safety
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/storage/eth-state-storage.test.ts | New test file validating genesis state caching behavior |
| tests/proofs/sig-onchain.test.ts | Added explicit type annotation for merklizeOpts |
| tests/handlers/auth.test.ts | Added explicit type annotation for merklizeOpts |
| tests/credentials/credential-validation.test.ts | Updated mock StateInfo to include required id field |
| src/utils/did-helper.ts | Extracted getIsGenesisStateById utility function |
| src/storage/entities/state.ts | Made id field required in StateInfo interface |
| src/storage/blockchain/state.ts | Enhanced genesis state handling with error checking and caching; introduced defaultStateInfo constant |
| src/proof/verifiers/pub-signals-verifier.ts | Simplified resolve method by removing genesis state logic |
| package.json | Version bumped to 1.38.8 |
| package-lock.json | Dependency tree updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Streamline state handling in PubSignalsVerifier and EthStateStorage. Improve error handling and enforce required fields in StateInfo. Introduce a utility function for clarity and add tests to ensure proper caching behavior for genesis states. Update version to 1.38.8.