Skip to content

Conversation

@atticusofsparta
Copy link
Contributor

@atticusofsparta atticusofsparta commented Nov 6, 2025

…ameInfo on the owner key

Summary by CodeRabbit

  • Bug Fixes
    • Improved primary names synchronization to correctly process updates to names, owner assignments, and pending requests while properly managing data removal when applicable.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

A new patch function createPrimaryNamesPatch is added to build Hyperbeam primary names sync payloads. The implementation uses a new dependency to fetch owner data with enhanced handling for name, owner, and request changes. The source modules are updated to integrate this new function and its dependencies, with minor formatting adjustments.

Changes

Cohort / File(s) Summary
New primary names patch
patches/2025-11-06-primary-names-hb-sync-fix.lua
Adds createPrimaryNamesPatch() function that constructs a patch payload for Hyperbeam primary names sync by collecting changes to names, owners, and requests; applies logic to nuke or omit empty sections.
Source module updates
src/hb.lua, src/primary_names.lua
Introduces dependency on primary_names module for fetching owner data; adds type annotation for affected primary names structure; minor formatting cleanup to remove empty line in return table.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • patches/2025-11-06-primary-names-hb-sync-fix.lua: New patch function introduces custom logic for handling primary names state changes; verify nil/empty handling, nuke vs. remove semantics, and data source compatibility
  • src/hb.lua: Owner data fetching refactored to use new dependency; ensure the new getPrimaryNameDataWithOwnerFromAddress() function returns compatible data structure and handles edge cases

Possibly related PRs

Suggested reviewers

  • arielmelendez

Poem

🐰 A patch for names, so crisp and clean,
Primary records, beautifully seen!
Sync the changes, remove or nuke,
Hyperbeam magic, the rabbit's rebuke! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: updating createPrimaryNamesPatch to use PrimaryNameInfo on the owner key, which aligns with the modifications across the three files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-primary-names-sync

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.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.36%. Comparing base (36fd94d) to head (6ba1787).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #444   +/-   ##
========================================
  Coverage    91.36%   91.36%           
========================================
  Files           10       10           
  Lines         3230     3230           
========================================
  Hits          2951     2951           
  Misses         279      279           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
patches/2025-11-06-primary-names-hb-sync-fix.lua (1)

9-71: Patch implementation correctly mirrors the updated function.

The patch appropriately overrides the createPrimaryNamesPatch function with logic identical to the updated version in src/hb.lua, enabling hot-fix deployment.

Note: The same concern about uni-directional iteration (flagged in src/hb.lua lines 57-60) applies here. If that verification reveals an issue, this patch will need updating as well.

🧹 Nitpick comments (1)
src/hb.lua (1)

35-40: Type annotations improve clarity.

The explicit type annotations for affectedPrimaryNamesAddresses and the owners field enhance type safety and IDE support.

Note: The type annotation on line 38 is redundant since line 35 already specifies owners: table<string, PrimaryNameInfo>. You can remove line 38 if desired:

 	local affectedPrimaryNamesAddresses = {
 		names = {},
-		---@type table<string, PrimaryNameInfo>
 		owners = {},
 		requests = {},
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36fd94d and 6ba1787.

📒 Files selected for processing (3)
  • patches/2025-11-06-primary-names-hb-sync-fix.lua (1 hunks)
  • src/hb.lua (3 hunks)
  • src/primary_names.lua (0 hunks)
💤 Files with no reviewable changes (1)
  • src/primary_names.lua
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: atticusofsparta
Repo: ar-io/ar-io-network-process PR: 442
File: src/hb.lua:7-27
Timestamp: 2025-11-03T22:41:58.658Z
Learning: In `src/hb.lua`, the `hb.createBalancesPatch()` function intentionally iterates both `Balances` and `HyperbeamSync.balances` in two separate loops to detect all changes (additions, modifications, and removals) for complete remote store synchronization. The `HyperbeamSync.balances` table holds a snapshot of balances before handlers run, so comparing in both directions ensures every altered address is included in the patch sent to Hyperbeam.
Learnt from: atticusofsparta
Repo: ar-io/ar-io-network-process PR: 435
File: src/main.lua:0-0
Timestamp: 2025-10-08T16:45:02.923Z
Learning: In `src/main.lua`, the owner-triggered manual `Patch-Hyperbeam-Balances` handler deliberately omits the `info.supply` field that `hb.patchBalances()` includes. The manual patch is for one-time initialization of Hyperbeam state, while automatic patches handle ongoing state synchronization with supply information.
📚 Learning: 2025-11-03T22:41:58.658Z
Learnt from: atticusofsparta
Repo: ar-io/ar-io-network-process PR: 442
File: src/hb.lua:7-27
Timestamp: 2025-11-03T22:41:58.658Z
Learning: In `src/hb.lua`, the `hb.createBalancesPatch()` function intentionally iterates both `Balances` and `HyperbeamSync.balances` in two separate loops to detect all changes (additions, modifications, and removals) for complete remote store synchronization. The `HyperbeamSync.balances` table holds a snapshot of balances before handlers run, so comparing in both directions ensures every altered address is included in the patch sent to Hyperbeam.

Applied to files:

  • patches/2025-11-06-primary-names-hb-sync-fix.lua
  • src/hb.lua
📚 Learning: 2025-10-08T16:45:02.923Z
Learnt from: atticusofsparta
Repo: ar-io/ar-io-network-process PR: 435
File: src/main.lua:0-0
Timestamp: 2025-10-08T16:45:02.923Z
Learning: In `src/main.lua`, the owner-triggered manual `Patch-Hyperbeam-Balances` handler deliberately omits the `info.supply` field that `hb.patchBalances()` includes. The manual patch is for one-time initialization of Hyperbeam state, while automatic patches handle ongoing state synchronization with supply information.

Applied to files:

  • patches/2025-11-06-primary-names-hb-sync-fix.lua
  • src/hb.lua
📚 Learning: 2025-10-08T16:44:07.797Z
Learnt from: atticusofsparta
Repo: ar-io/ar-io-network-process PR: 435
File: src/hb.lua:0-0
Timestamp: 2025-10-08T16:44:07.797Z
Learning: In `src/hb.lua`, the `hb.patchBalances()` function intentionally uses the global `Balances` variable directly and only accepts `oldBalances` as a parameter, rather than accepting both old and new balances as parameters.

Applied to files:

  • patches/2025-11-06-primary-names-hb-sync-fix.lua
  • src/hb.lua
🧬 Code graph analysis (2)
patches/2025-11-06-primary-names-hb-sync-fix.lua (1)
src/primary_names.lua (1)
  • primaryNames.getPrimaryNameDataWithOwnerFromAddress (310-322)
src/hb.lua (1)
src/primary_names.lua (1)
  • primaryNames.getPrimaryNameDataWithOwnerFromAddress (310-322)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: sdk
🔇 Additional comments (4)
src/hb.lua (3)

3-3: Good addition of the primary names dependency.

This import enables access to the enhanced owner data retrieval function.


59-59: Enhanced owner data format aligns with PR objective.

Using getPrimaryNameDataWithOwnerFromAddress correctly provides SDK-compatible owner information including the processId field, with proper fallback to {} for removals.


57-60: Uni-directional iteration appears intentional but uses different architecture than balances.

The createBalancesPatch uses a snapshot model storing previous values, enabling bidirectional comparison. The createPrimaryNamesPatch uses a dirty flag model, iterating only HyperbeamSync.primaryNames.* entries marked as true during mutations.

The dirty flag approach works because all mutations in src/primary_names.lua explicitly set the corresponding flags (lines 150, 236-238, 260-261, 290-292, 370-371, 436). However, this is less robust than the snapshot pattern—if tracking discipline breaks or state is modified outside tracked functions, changes could be missed.

Consider either: (1) confirm this architectural difference is intentional, or (2) refactor createPrimaryNamesPatch to match the snapshot comparison pattern used by createBalancesPatch for consistency and resilience.

patches/2025-11-06-primary-names-hb-sync-fix.lua (1)

1-8: Clear patch documentation.

The header comment clearly explains the purpose and scope of this patch, aligning with the PR objective.

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.

3 participants