Skip to content

Update StreamRegistry.sol#4858

Open
syed-ghufran-hassan wants to merge 1 commit into
towns-protocol:mainfrom
syed-ghufran-hassan:patch-1
Open

Update StreamRegistry.sol#4858
syed-ghufran-hassan wants to merge 1 commit into
towns-protocol:mainfrom
syed-ghufran-hassan:patch-1

Conversation

@syed-ghufran-hassan

@syed-ghufran-hassan syed-ghufran-hassan commented Jan 13, 2026

Copy link
Copy Markdown

The implementation uses calldata parameters but the interface specifies memory. This will cause the contract to fail the interface check so I have changed it from calldata to memory.

Description

Updated function parameters from calldata to memory for interface compliance.

Changes

  • Updated function parameters from calldata to memory for interface compliance.

Checklist

  • Tests added where required
  • Documentation updated where applicable
  • Changes adhere to the repository's contribution guidelines

Changeset

Did you modify any published npm packages?

  • Yes → I ran bun changeset and described my changes (use patch for most changes)
  • No → This only affects /core, docs, CI, or private packages

 The implementation uses calldata parameters but the interface specifies memory. This will cause the contract to fail the interface check so I have changed it from calldata to memory.
@vercel

vercel Bot commented Jan 13, 2026

Copy link
Copy Markdown

@syed-ghufran-hassan is attempting to deploy a commit to the River Build Team Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jan 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The allocateStream function signature in StreamRegistry.sol is modified to change two array/byte parameters from calldata to memory, altering the function's ABI for external calls while maintaining identical runtime logic.

Changes

Cohort / File(s) Summary
StreamRegistry Function Signature
packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
Changed parameter data locations from calldata to memory for address[] nodes and bytes genesisMiniblock in allocateStream function

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive terms like 'Update' that don't convey the specific change being made. Replace with a more descriptive title like 'Fix StreamRegistry.sol parameter types from calldata to memory for interface compliance'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the issue (calldata vs memory mismatch) and the solution applied to fix interface compliance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

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/stream/StreamRegistry.sol:
- Around line 32-37: Change the external function signatures to use calldata for
array/bytes params: update IStreamRegistry.allocateStream to declare nodes and
genesisMiniblock as calldata and then update StreamRegistry.allocateStream to
match (nodes and genesisMiniblock parameters as calldata) so external calls
avoid unnecessary memory copies; also reconcile the related addStream mismatch
by making the interface and implementation signatures consistent (use Stream
calldata in the interface or change implementation to Stream memory) and adjust
any callers accordingly.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de09c2c and b87f2bc.

📒 Files selected for processing (1)
  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
🧰 Additional context used
📓 Path-based instructions (3)
packages/contracts/**/*.sol

📄 CodeRabbit inference engine (packages/contracts/.cursor/rules/design-philosophy.mdc)

packages/contracts/**/*.sol: Minimize complexity in software structure, prioritizing obviousness and ease of modification in Solidity contracts and facets
Invest time in design upfront rather than quick tactical fixes; prioritize long-term structure over short-term convenience when adding new facets or features
Design code to be obvious: developers should quickly understand existing code and confidently make changes without requiring multiple file traces and dependency navigation
Minimize coupling between modules; use events and interfaces to decouple components so changes in one facet rarely require changes in others
Name entities precisely and document non-obvious behavior; if a function's purpose isn't clear from its signature and name, the design needs improvement
Avoid change amplification: small logical changes should not require modifying many files; high coupling indicates architecture problems
Reduce cognitive load by making facet interfaces self-documenting and isolating storage layouts so developers don't need extensive context to complete tasks
Make it obvious which code must be modified for a given change through clear module boundaries and interfaces to prevent hidden dependencies
Strive for deep modules in Solidity: provide powerful functionality through simple interfaces while hiding complex implementation details
Design facet interfaces to be minimal and clear, hiding internal complexity such as cross-chain calls, rule evaluation, and caching logic
Design facets to be somewhat general-purpose; separate specialized logic from general mechanisms to maximize code reusability
Implement information hiding to ensure each facet has isolated storage slots and facets communicate through libraries, abstracts, or well-defined interfaces rather than shared knowledge
Do not expose storage layout details of one facet to another; each facet must have isolated storage and communicate through interfaces
Avoid temporal decomposition: do not structure code solely ba...

Files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
packages/contracts/src/**/*.sol

📄 CodeRabbit inference engine (packages/contracts/AGENTS.md)

Organize contract code with separate Storage library, Base contract with internal logic, and Facet contract with external interface

Files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
**/*.{ts,tsx,js,jsx,yaml,yml,sol,json,md}

📄 CodeRabbit inference engine (AGENTS.md)

All non-Go files must pass Prettier formatting, run bun run prettier:fix to automatically format TypeScript, JavaScript, YAML, Solidity, and other supported files

Files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: towns-protocol/towns PR: 0
File: packages/contracts/AGENTS.md:0-0
Timestamp: 2025-12-06T08:15:28.770Z
Learning: Applies to packages/contracts/**/*.sol : Use `calldata` for external function parameters that are arrays or strings instead of `memory`
Learnt from: CR
Repo: towns-protocol/towns PR: 0
File: packages/contracts/.cursor/rules/contracts.mdc:0-0
Timestamp: 2026-01-08T23:23:01.042Z
Learning: Applies to packages/contracts/**/*.sol : Use calldata in external function argument definitions when possible
Learnt from: shuhuiluo
Repo: towns-protocol/towns PR: 3926
File: packages/contracts/src/factory/facets/feature/FeatureManagerFacet.sol:51-58
Timestamp: 2025-08-22T07:50:18.536Z
Learning: In the towns-protocol contracts, the memory optimization pattern `mstore(0x40, result)` where `result` is a named return variable is extensively used across the codebase in getter functions. When a named return variable is declared, Solidity pre-allocates memory for it, but if the variable gets assigned from a function call that returns a struct, new memory is allocated for the actual data, making the pre-allocated space unused. Reclaiming this space by resetting the free memory pointer is a well-documented gas optimization technique used consistently in files like StreamRegistry.sol, RewardsDistributionV2.sol, MainnetDelegationBase.sol, ReviewFacet.sol, and DropFacet.sol with detailed explanatory comments.
Learnt from: shuhuiluo
Repo: towns-protocol/towns PR: 3926
File: packages/contracts/src/factory/facets/feature/FeatureManagerFacet.sol:51-58
Timestamp: 2025-08-22T07:50:18.536Z
Learning: In the towns-protocol contracts, the memory optimization pattern `mstore(0x40, result)` where `result` is a named return variable is extensively used across the codebase in getter functions. When a named return variable is declared, Solidity pre-allocates memory for it, but if the variable gets assigned from a function call that returns a struct, new memory is allocated for the actual data, making the pre-allocated space unused. Reclaiming this space by resetting the free memory pointer is a well-documented gas optimization technique used consistently in files like StreamRegistry.sol, RewardsDistributionV2.sol, MainnetDelegationBase.sol, ReviewFacet.sol, and DropFacet.sol with detailed explanatory comments.
📚 Learning: 2025-12-06T08:15:28.770Z
Learnt from: CR
Repo: towns-protocol/towns PR: 0
File: packages/contracts/AGENTS.md:0-0
Timestamp: 2025-12-06T08:15:28.770Z
Learning: Applies to packages/contracts/**/*.sol : Use `calldata` for external function parameters that are arrays or strings instead of `memory`

Applied to files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
📚 Learning: 2025-12-06T08:16:19.499Z
Learnt from: CR
Repo: towns-protocol/towns PR: 0
File: protocol/AGENTS.md:0-0
Timestamp: 2025-12-06T08:16:19.499Z
Learning: Applies to protocol/**/*.proto : Use `bytes` for Ethereum addresses (20 bytes) and stream IDs (32 bytes) in protobuf messages

Applied to files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
📚 Learning: 2025-12-19T20:33:59.100Z
Learnt from: shuhuiluo
Repo: towns-protocol/towns PR: 4717
File: packages/contracts/test/spaces/membership/unit/MembershipCurrencyMigration.t.sol:2-2
Timestamp: 2025-12-19T20:33:59.100Z
Learning: In Foundry projects, the compiler version is governed by foundry.toml; file-level pragmas only need to be compatible. Do not require exact version matches. Ensure pragma solidity in .sol files is compatible with the version configured in foundry.toml and avoid mismatches that would cause compilation issues.

Applied to files:

  • packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol

Comment on lines 32 to 37
function allocateStream(
bytes32 streamId,
address[] calldata nodes,
address[] memory nodes,
bytes32 genesisMiniblockHash,
bytes calldata genesisMiniblock
bytes memory genesisMiniblock
) external onlyNode(msg.sender) onlyStreamNotExists(streamId) onlyRegisteredNodes(nodes) {

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the StreamRegistry.sol file around lines 32-37
cat -n packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol | sed -n '30,90p'

Repository: towns-protocol/towns

Length of output: 2641


🏁 Script executed:

#!/bin/bash
# Look for IStreamRegistry interface definition
find packages/contracts -name "*IStreamRegistry*" -o -name "*StreamRegistry*" | grep -i interface

Repository: towns-protocol/towns

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Check other function signatures in StreamRegistry.sol to see parameter patterns
grep -n "external\|public" packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol | head -20

Repository: towns-protocol/towns

Length of output: 1026


🏁 Script executed:

#!/bin/bash
# Search for IStreamRegistry interface definition
find packages/contracts -type f -name "*.sol" | xargs grep -l "interface IStreamRegistry"

Repository: towns-protocol/towns

Length of output: 135


🏁 Script executed:

#!/bin/bash
# Also check if there's an interface in the same directory or common paths
find packages/contracts/src/river/registry -type f -name "*.sol" | sort

Repository: towns-protocol/towns

Length of output: 764


🏁 Script executed:

#!/bin/bash
# Check the IStreamRegistry interface definition for allocateStream
cat packages/contracts/src/river/registry/facets/stream/IStreamRegistry.sol

Repository: towns-protocol/towns

Length of output: 7072


Interface should specify calldata for array/bytes parameters per project guidelines.

Both IStreamRegistry.allocateStream and StreamRegistry.allocateStream use memory for the nodes and genesisMiniblock parameters. Project guidelines and learnings require calldata for external function array and bytes parameters—this saves gas by avoiding memory allocation.

Update IStreamRegistry to use calldata, then update the implementation accordingly. Note: addStream has a related issue where the interface specifies Stream memory but the implementation uses Stream calldata.

🤖 Prompt for AI Agents
In @packages/contracts/src/river/registry/facets/stream/StreamRegistry.sol
around lines 32 - 37, Change the external function signatures to use calldata
for array/bytes params: update IStreamRegistry.allocateStream to declare nodes
and genesisMiniblock as calldata and then update StreamRegistry.allocateStream
to match (nodes and genesisMiniblock parameters as calldata) so external calls
avoid unnecessary memory copies; also reconcile the related addStream mismatch
by making the interface and implementation signatures consistent (use Stream
calldata in the interface or change implementation to Stream memory) and adjust
any callers accordingly.

@shuhuiluo

Copy link
Copy Markdown
Contributor

Obviously the contracts compile. Change memory to calldata in the interface instead.

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.

2 participants