Skip to content

fix app operate with zero allocations#401

Merged
dimast-x merged 1 commit into
fix/asu-notiffrom
fix/operate
Oct 24, 2025
Merged

fix app operate with zero allocations#401
dimast-x merged 1 commit into
fix/asu-notiffrom
fix/operate

Conversation

@dimast-x
Copy link
Copy Markdown
Contributor

No description provided.

@dimast-x dimast-x requested a review from a team as a code owner October 24, 2025 05:27
@dimast-x dimast-x changed the base branch from main to fix/asu-notif October 24, 2025 05:27
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 24, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/operate

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @dimast-x, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the application's Operate intent could not properly handle zero-amount allocations. The changes ensure that such allocations are correctly processed and verified, preventing errors and allowing for more flexible state management within application sessions. A new test case has been added to confirm this functionality.

Highlights

  • Zero Allocation Handling: Modified the OperateUpdater to correctly process allocations with zero amounts, ensuring they are included in the allocationSum calculation.
  • Allocation Verification Logic: Updated the verifyAllocations function to permit allocationSum entries for assets not present in appSessionBalance, provided their total sum is zero. This prevents errors when dealing with zero-value allocations for new or uninitialized assets.
  • New Test Case: Introduced a new test case to validate the successful submission of an Operate intent with zero-amount allocations, confirming the intended behavior.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
clearnode/rpc_router_private.go 33.33% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes an issue where operate intents with zero-value allocations would fail. The changes in app_session_service.go and rpc_router_private.go properly handle these zero allocations by allowing them during balance verification, as long as they don't introduce new non-zero balances for unlisted assets. A new test case has been added to cover this scenario, which is excellent for ensuring the fix is robust. I've pointed out a small improvement in the new test to handle errors explicitly, which will make the test more reliable.

Comment on lines +418 to +421
appBalA, _ := GetWalletLedger(db, userAddressA).Balance(sessionAccountID, "usdc")
appBalB, _ := GetWalletLedger(db, userAddressB).Balance(sessionAccountID, "usdc")
assert.True(t, appBalA.IsZero())
assert.True(t, appBalB.IsZero())
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.

medium

The errors returned from the Balance calls are being ignored. The Balance function returns decimal.Zero on error, which could cause this test to pass silently even if there's an issue with retrieving the balance. It's safer to check for errors explicitly using require.NoError(t, err).

		appBalA, errA := GetWalletLedger(db, userAddressA).Balance(sessionAccountID, "usdc")
		require.NoError(t, errA)
		appBalB, errB := GetWalletLedger(db, userAddressB).Balance(sessionAccountID, "usdc")
		require.NoError(t, errB)
		assert.True(t, appBalA.IsZero())
		assert.True(t, appBalB.IsZero())

@dimast-x dimast-x merged commit da197cb into fix/asu-notif Oct 24, 2025
13 checks passed
@dimast-x dimast-x deleted the fix/operate branch October 24, 2025 05:34
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.

1 participant