Skip to content

bugfix(serviveability): require ip-net for CYOA interfaces#3033

Open
bgm-malbeclabs wants to merge 6 commits intomainfrom
bgm/enforce_cyoa_ip-net
Open

bugfix(serviveability): require ip-net for CYOA interfaces#3033
bgm-malbeclabs wants to merge 6 commits intomainfrom
bgm/enforce_cyoa_ip-net

Conversation

@bgm-malbeclabs
Copy link
Contributor

@bgm-malbeclabs bgm-malbeclabs commented Feb 17, 2026

Summary of Changes

This PR adds the requirement to have an ip_net when a CYOA interface is created. Previously one could create a CYOA interface without an ip_net which would default to 0.0.0.0 which doesn't seem like desired behavior.

Closes #3032

Testing Verification

  • E2E tests have been updated to include the ip-net flag for CYOA interfaces

@bgm-malbeclabs bgm-malbeclabs marked this pull request as draft February 17, 2026 20:58
@bgm-malbeclabs bgm-malbeclabs changed the title bugfix(serviveability): close orphaned blocks when dz_prefixes shrink bugfix(serviveability): require ip-net for CYOA interfaces Feb 17, 2026
@bgm-malbeclabs bgm-malbeclabs force-pushed the bgm/enforce_cyoa_ip-net branch from 285a719 to 8ffc9d1 Compare February 17, 2026 23:39
@bgm-malbeclabs bgm-malbeclabs requested review from ben-malbeclabs, Copilot, elitegreg and nikw9944 and removed request for Copilot and elitegreg February 18, 2026 00:10
@bgm-malbeclabs bgm-malbeclabs marked this pull request as ready for review February 18, 2026 00:10
Copy link
Contributor

Copilot AI left a 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 addresses a bug where CYOA (Choose Your Own Adventure) interfaces could be created without an ip_net, which would default to 0.0.0.0. The fix adds validation in the interface creation processor to require that CYOA interfaces must have an ip_net specified.

Changes:

  • Added validation to require ip_net for CYOA interfaces during creation
  • Added validation to restrict CYOA to physical interfaces only
  • Updated E2E tests to include ip-net flag when creating CYOA interfaces

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
smartcontract/programs/doublezero-serviceability/src/processors/device/interface/create.rs Added two new validation checks: CYOA can only be set on physical interfaces, and CYOA interfaces must have an ip_net
e2e/link_onchain_allocation_test.go Updated CYOA interface creation commands to include --ip-net flag
e2e/interface_validation_test.go Updated existing test to include --ip-net flag when creating CYOA interface
CHANGELOG.md Added entry documenting the requirement for ip-net on CYOA interfaces

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +128
// CYOA interfaces must have an ip_net
if value.interface_cyoa != InterfaceCYOA::None && value.ip_net.is_none() {
return Err(DoubleZeroError::InvalidInterfaceIp.into());
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation requiring CYOA interfaces to have an ip_net is only enforced during interface creation. However, this same validation should also be added to:

  1. The validate() function in interface.rs (around line 449) to ensure this constraint is checked consistently across all operations
  2. The update processor in update.rs to prevent setting interface_cyoa without an ip_net or clearing ip_net from a CYOA interface

Without these additional checks, it's possible to create inconsistent states through the update operation or have interfaces that pass validation but violate this business rule.

Copilot uses AI. Check for mistakes.
Comment on lines +125 to +128
// CYOA interfaces must have an ip_net
if value.interface_cyoa != InterfaceCYOA::None && value.ip_net.is_none() {
return Err(DoubleZeroError::InvalidInterfaceIp.into());
}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new validation enforces that CYOA interfaces must have an ip_net, but the existing unit test test_cyoa_on_physical_valid in interface.rs (lines 614-619) creates a CYOA interface without an ip_net and expects validation to pass. This test should be updated to include an ip_net to align with the new business rule, or a new test should be added to verify that CYOA without ip_net is rejected during creation.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +64
_, err := dn.Manager.Exec(t.Context(), []string{
"doublezero", "device", "interface", "create",
testDeviceCode, testInterfaceName,
"--interface-cyoa", "gre-over-dia",
"--ip-net", "45.33.100.50/31",
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the E2E tests have been updated to include ip-net when creating CYOA interfaces, there's no negative test case to verify that creating a CYOA interface WITHOUT an ip-net is properly rejected. Consider adding a test case similar to "cyoa_on_loopback_rejected" that attempts to create a CYOA physical interface without ip-net and verifies that it fails with the appropriate error.

Copilot uses AI. Check for mistakes.
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.

Require ip-net for CYOA interfaces

1 participant

Comments