Skip to content

feat(contracts): add batch node status update for config managers#4886

Open
bas-vk wants to merge 2 commits into
mainfrom
feat/batch-node-status-update
Open

feat(contracts): add batch node status update for config managers#4886
bas-vk wants to merge 2 commits into
mainfrom
feat/batch-node-status-update

Conversation

@bas-vk

@bas-vk bas-vk commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add updateNodesStatusConfigManager function to allow configuration managers to update multiple node statuses in a single transaction
  • Extract shared logic into _updateNodeStatus internal function used by both updateNodeStatus and updateNodesStatusConfigManager
  • Add comprehensive unit tests for the new functionality

Test plan

  • All 29 NodeRegistry tests pass
  • New tests cover: batch updates, single node updates, empty arrays, auth checks, invalid transitions, and atomic rollback on partial failure

🤖 Generated with Claude Code

@vercel

vercel Bot commented Feb 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
river-sample-app Ready Ready Preview, Comment Feb 16, 2026 8:41am

Request Review

@coderabbitai

coderabbitai Bot commented Feb 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a batch API to update node statuses (configuration-manager-only), refactors per-node status update into an internal helper, updates deployment facet selectors to include the new method, and introduces tests for batch behavior, permissions, transitions, and atomicity.

Changes

Cohort / File(s) Summary
Deployment Configuration
packages/contracts/scripts/deployments/facets/DeployNodeRegistry.s.sol
Selector array length increased (12 → 13); inserted updateNodesStatusConfigManager selector at index 4 and shifted subsequent selectors.
Interface Definition
packages/contracts/src/river/registry/facets/node/INodeRegistry.sol
Added UpdateNodeStatusConfigManagerRequest struct and declaration of updateNodesStatusConfigManager(UpdateNodeStatusConfigManagerRequest[] calldata).
Core Implementation
packages/contracts/src/river/registry/facets/node/NodeRegistry.sol
Added internal helper _updateNodeStatus(address, NodeStatus); updateNodeStatus now delegates to it; added updateNodesStatusConfigManager(... ) external function restricted to configuration manager; updated event emission to use parameter address.
Tests
packages/contracts/test/river/registry/node/NodeRegistry.t.sol
Added extensive tests for updateNodesStatusConfigManager: multi/single/empty batches, permission checks, transition validation, event emission, atomic rollback on failures, and a givenConfigurationManagerIsApproved test helper.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • jterzis
  • pfives
  • giuseppecrj
  • shuhuiluo
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a batch node status update feature for configuration managers.
Description check ✅ Passed The description clearly outlines the changes: new batch update function, refactored shared logic, and comprehensive test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/batch-node-status-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/contracts/src/river/registry/facets/node/NodeRegistry.sol`:
- Around line 85-91: The config-manager path updateNodesStatusConfigManager
calls _updateNodeStatus without ensuring the target was ever registered,
allowing writes for uninitialized addresses because
_checkNodeStatusTransitionAllowed treats NotInitialized as permissive; update
_updateNodeStatus to assert the node exists before proceeding (the same
existence guard enforced by onlyNode in updateNodeStatus), e.g., require a
registration flag or that current node data is initialized, then proceed to call
_checkNodeStatusTransitionAllowed and emit NodeStatusUpdated as before to
prevent writing status for non-existent nodes.
🧹 Nitpick comments (3)
packages/contracts/src/river/registry/facets/node/INodeRegistry.sol (1)

26-44: Missing NatSpec on new struct and function.

The coding guidelines require NatSpec for all public/external functions. While most existing functions in this interface also lack it, consider adding @notice for the new batch function to document the configuration manager restriction and batch semantics.

packages/contracts/src/river/registry/facets/node/NodeRegistry.sol (1)

93-98: NatSpec missing on _updateNodeStatus and updateNodesStatusConfigManager.

Per coding guidelines, NatSpec (@notice, @param) is expected. Brief docs clarifying the lack of existence checks vs. reliance on callers would be especially valuable here.

packages/contracts/test/river/registry/node/NodeRegistry.t.sol (1)

440-628: Good coverage overall. Batch, single, empty, auth, invalid transitions, and atomicity are all tested.

One gap: add a test for batch-updating a non-existent node address. This exercises the missing existence check flagged in NodeRegistry.sol. Without it, a config manager could silently write to phantom storage slots.

Comment thread packages/contracts/src/river/registry/facets/node/NodeRegistry.sol
Add updateNodesStatusConfigManager function to allow configuration
managers to update multiple node statuses in a single transaction.
Extract shared logic into _updateNodeStatus internal function used
by both updateNodeStatus and updateNodesStatusConfigManager.

The internal function includes a node existence check to prevent
writing status for non-existent nodes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bas-vk bas-vk force-pushed the feat/batch-node-status-update branch from 901335b to 985ac9f Compare February 16, 2026 08:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/contracts/src/river/registry/facets/node/NodeRegistry.sol (1)

85-91: Batch function looks solid — add NatSpec.

Logic, access control, gas patterns (calldata, ++i) all check out. However, both updateNodesStatusConfigManager and _updateNodeStatus are missing NatSpec documentation, which is required per coding guidelines.

Suggested NatSpec
+    /// `@notice` Batch update node statuses by a configuration manager.
+    /// `@param` updates Array of node address and target status pairs.
     function updateNodesStatusConfigManager(
         UpdateNodeStatusConfigManagerRequest[] calldata updates
     ) external onlyConfigurationManager(msg.sender) {

As per coding guidelines: "Include NatSpec documentation for all public and external functions" and "Use NatSpec documentation format with @notice for brief descriptions, @dev for implementation details, @param for parameters, and @return for return values".

packages/contracts/test/river/registry/node/NodeRegistry.t.sol (1)

511-519: Empty array test — consider asserting no events emitted.

The test confirms no revert, but doesn't assert that zero NodeStatusUpdated events were emitted. Minor, since the loop body simply won't execute, but vm.recordLogs() + length check would make the intent explicit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
packages/contracts/test/river/registry/node/NodeRegistry.t.sol (3)

431-438: Consider adding fuzz-input collision guards.

The modifier doesn't guard against configManager colliding with nodeOperator, node1, node2, or deployer. While unlikely to cause failures here, adding vm.assume(configManager != nodeOperator) (etc.) in the individual test functions would make the fuzz space more intentional and avoid accidental overlap of roles.


597-646: Solid atomicity test. One optional addition: assert node2 status is still Operational after the revert for symmetry with the node1 check. The EVM revert guarantees it, but it documents intent.

Optional: assert node2 unchanged too
         // Verify node1 status was NOT updated (transaction reverted)
         Node memory nodeData1 = nodeRegistry.getNode(node1);
         assertEq(uint256(nodeData1.status), uint256(NodeStatus.NotInitialized));
+
+        // Verify node2 status was NOT changed either
+        Node memory nodeData2 = nodeRegistry.getNode(node2);
+        assertEq(uint256(nodeData2.status), uint256(NodeStatus.Operational));

426-646: Consider adding a test for duplicate node addresses within a single batch.

What happens if the same node appears twice in the updates array (e.g., NotInitialized → Operational then Operational → Departing)? This is a valid edge case — sequential application within a batch could either succeed (chained transitions) or fail depending on implementation. Worth codifying the expected behavior.

@blacksmith-sh

blacksmith-sh Bot commented Feb 16, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
node/rpc/TestGetMiniblocksTerminusForwardingToRemotes View Logs

Fix in Cursor

@bas-vk bas-vk enabled auto-merge (squash) February 17, 2026 09:48
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.

4 participants