Skip to content

Conversation

Yuri0405
Copy link

@Yuri0405 Yuri0405 commented Jul 2, 2025

Summary

Implements automatic peer protocol version detection for collation request versioning as described in issue #4711.

Problem

The collator validator-side subsystem needed to support versioned collation requests to accommodate both V1 and V2 protocols, but lacked automatic peer version detection.

Solution

Automatic Version Detection

  • Peers are automatically upgraded to ProtocolV2 when they send AdvertiseCollationV2 messages
  • Maintains backward compatibility by defaulting new peers to ProtocolV1
  • No manual configuration required

Version-Aware Request Formatting

  • V1 Protocol: CollationFetchingRequestV1 { relay_parent, para_id }
  • V2 Protocol: CollationFetchingRequestV2 { relay_parent, para_id, candidate_hash }
  • Requests are automatically formatted based on peer's detected protocol version

Implementation Details

  • Added setPeerProtocolVersion() method for automatic peer upgrades
  • Enhanced requestCollation() to select appropriate request format based on peer version
  • Modified processCollatorProtocolMessage() to handle V2 advertisements with auto-upgrade logic

Testing

  • Comprehensive test suite validates V1/V2 request format selection
  • Tests verify V2 candidate hash requirements
  • Network timeout and success scenarios covered
  • Auto-upgrade functionality verified

Verification

Peers now automatically use the correct request format (V1/V2) based on their advertisement capabilities without manual intervention.

Fixes #4711

Files Changed

  • validator-side/message.go - V2 advertisement handling with auto-upgrade
  • validator-side/collation_fetching.go - Version-aware request logic
  • validator-side/validator_side.go - Peer version management
  • messages/protocol_messages.go - V2 message structures
  • validator-side/validator_side_test.go - Comprehensive test coverage

@Yuri0405 Yuri0405 force-pushed the feat/parachain-collation-fetching-v2 branch from 74ff9d9 to 6e2c20c Compare July 2, 2025 13:14
Yuri0405 added 6 commits July 2, 2025 16:17
…ng requests (ChainSafe#4711)

Implement timeout handling in requestCollation to prevent hanging on
unresponsive peers. Includes comprehensive test coverage for timeout
and success scenarios.
…re for collation requests (ChainSafe#4711)

- Add CollationRequestInfo struct to track request metadata
- Implement channel-based communication between request initiation and timeout detection
- Add periodic cleanup ticker (10ms) to detect expired requests (100ms timeout)
- Track active requests in Run() loop with proper cleanup
- Foundation for actual network request cancellation in future commits

Related to Polkadot timeout behavior implementation
…llation (ChainSafe#4711)

- Use unified maxUnsharedDownloadTime (100ms) for both tracking and network timeouts
- Actually cancel network requests when timeout detected in cleanup ticker
- Add requestCompletions channel for proper request lifecycle management
- Prevents resource leakage from expired requests
…upport for V1/V2 collation request formats with dynamic peer version detection:

- Add CollationFetchingRequestV1/V2 with proper SCALE encoding
- Add AdvertiseCollationV2 message support
- Implement peer version tracking with auto-upgrade capability
- Add version-aware request selection logic
- Maintain full backward compatibility (default V1)
- Handle proper peer lifecycle and cleanup
…ainSafe#4711)

- Test V1/V2 peer protocol version management
- Validate V2 candidate hash requirement
- Add network timeout/success/error scenarios
- Fix segfault by removing problematic goroutine calls
- Use proper mocking for isolated unit tests

Validates that V1 peers use RequestV1 format and V2 peers require
candidate hash with RequestV2 format.
…nSafe#4711)

- Upgrade peer to ProtocolV2 when receiving V2 advertisement
- Remove redundant V1 default in PeerConnected handler
- Complete automatic version detection for collation requests
@Yuri0405 Yuri0405 force-pushed the feat/parachain-collation-fetching-v2 branch from 6e2c20c to 97aaecc Compare July 2, 2025 15:14
Yuri0405 added 3 commits July 10, 2025 16:45
- Remove validateCollatorHandshake (unused stub)
- Remove getCollatorHandshake (unused stub)
- Remove decodeCollationMessage (unused stub)
- Remove unused pkg/scale import

Fixes DeepSource SCC-U1000 issues.
- Update all ValueAt methods to use pointer receivers
- Fix CollationFetchingResponse methods
- Fix CollationProtocol methods
- Fix CollatorProtocolMessage methods

Resolves DeepSource RVV-B0013 issue.
- convert all CollatorProtocolMessage methods to pointer receivers
- convert all CollationFetchingResponse methods to pointer receivers
- convert all CollationProtocol methods to pointer receivers
- remove unused receiver variable names

Resolves DeepSource issue GO-W1029
@Yuri0405 Yuri0405 force-pushed the feat/parachain-collation-fetching-v2 branch from 1c27c96 to 22b97d4 Compare July 11, 2025 12:33
@Yuri0405
Copy link
Author

Hi @EclesioMeloJunior!
I passed DeepSource analyzer check, could you please approve the pending CI workflow and/or check my PR?
Thank you for your time!

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