Feat/circular dependency fix #48
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: add circular dependency resolution for validation schemas
Summary
Changes
Automatic Circular Dependency Detection
CIRCULAR_DEPENDENCY_MAPfor FieldRules ↔ MapRules ↔ RepeatedRules relationshipsis_circular_dependency()andshould_use_bytes_for_field()functionsBytes Field Solution
bytesrepresentation with descriptive commentsIntegration Across Generation Pipeline
Technical Details
Files Modified:
protobuf-solidity/src/protoc/plugin/gen_util.py- Added circular dependency detection logicprotobuf-solidity/src/protoc/plugin/gen_decoder.py- Updated to use bytes decoder for circular fieldsprotobuf-solidity/src/protoc/plugin/gen_encoder.py- Updated to handle circular fields as bytesprotobuf-solidity/src/protoc/plugin/gen_sol.py- Updated struct generation with circular field handlingREADME.md- Added Circular Dependency Resolution documentation sectionKey Functions Added:
is_circular_dependency(msg, field)- Detects circular referencesshould_use_bytes_for_field(msg, field)- Determines if bytes conversion neededCircular Dependencies Resolved:
Example Output
Test Plan
Dependencies
This PR builds on
feat/solidity-compatibilityfor the field name mangling functionality used throughout the circular dependency resolution system.Impact
Enables buf/validate and other validation schemas with circular dependencies to work seamlessly with the Solidity protobuf generator, expanding the plugin's capability to handle complex validation scenarios.