Skip to content

feat(devnet-sdk): add chain descriptor validation #16523

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DeVikingMark
Copy link

Description

Replaces TODO comments in chain.go with comprehensive descriptor validation to prevent runtime panics when creating chains from malformed descriptors. Adds validation functions for chain descriptors, node configurations, and L2 chain structures with clear error messages.

Tests

  • TestChainFromDescriptorValidation with 9 test cases covering nil descriptors, empty chain IDs, missing nodes, invalid services/endpoints, and port validation
  • TestL2ChainFromDescriptorValidation with 3 test cases for L2-specific validation scenarios
  • All existing tests continue to pass, ensuring no regression

Additional context

The original code had TODO comments indicating potential panic situations in newChainFromDescriptor() and newL2ChainFromDescriptor() functions. Without proper validation, the code could panic when accessing nested descriptor fields that might be nil or missing. This fix ensures graceful error handling with descriptive error messages while maintaining full backward compatibility.

Metadata

@DeVikingMark DeVikingMark requested a review from a team as a code owner June 20, 2025 12:11
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.

Handle incorrect descriptors better in devnet-sdk/system/chain.go
1 participant