Skip to content

bugfix(cli): prevent a user from adding a duplicate IP (#3056)#3139

Merged
bgm-malbeclabs merged 4 commits intomainfrom
bgm/cli_dup_ip_check
Feb 27, 2026
Merged

bugfix(cli): prevent a user from adding a duplicate IP (#3056)#3139
bgm-malbeclabs merged 4 commits intomainfrom
bgm/cli_dup_ip_check

Conversation

@bgm-malbeclabs
Copy link
Contributor

Summary of Changes

This PR adds an IP duplicate check at the CLI (but not on the smart contract) to prevent a user from accidentally adding a duplicate IP. Devices are fetched, then filtered to the user's devices, and then the check is peformed on both create and update. If there is a duplicate detected, an error is returned.

Closes #3056

Testing Verification

  • Unit test updated to validate that a duplicate IP on create and update returns an error

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

Adds a CLI-side safeguard to prevent assigning the same IPv4 network to multiple interfaces owned by the same contributor, addressing accidental duplicate on-chain interface IP assignments (Issue #3056).

Changes:

  • Add duplicate ip_net detection across all devices belonging to the same contributor_pk during device interface create.
  • Add the same duplicate ip_net detection during device interface update, while attempting to skip the interface being updated.
  • Update unit tests to cover duplicate-IP failures for both create and update, and document the change in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
smartcontract/cli/src/device/interface/update.rs Parses --ip-net, checks for duplicates across contributor devices before issuing the update, and adds tests for duplicate-IP rejection.
smartcontract/cli/src/device/interface/create.rs Checks for duplicates across contributor devices before creating an interface, and adds a test for duplicate-IP rejection.
CHANGELOG.md Notes the new CLI duplicate-IP prevention behavior.

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

@bgm-malbeclabs bgm-malbeclabs merged commit 43c61b6 into main Feb 27, 2026
30 checks passed
@bgm-malbeclabs bgm-malbeclabs deleted the bgm/cli_dup_ip_check branch February 27, 2026 20:35
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.

Shouldn't be possible to assign the same address to multiple interfaces

4 participants