Skip to content

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Aug 13, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted transaction validation to require a deployment allowance only for deployment actions. Non-deployment transactions are no longer blocked by missing deployment allowances, reducing erroneous rejections.
    • Preserves existing fee checks and behavior for deployment-related transactions, ensuring consistent validation where applicable.

@baktun14 baktun14 requested a review from a team as a code owner August 13, 2025 14:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

The deployment allowance assertion is now executed only when a message of type "/akash.deployment.v1beta3.MsgCreateDeployment" is present. For non-deployment messages, deployment allowance validation is skipped. Other validations, including fee allowance checks, remain unchanged. No public signatures were modified.

Changes

Cohort / File(s) Summary
Managed Signer Service
apps/api/src/billing/services/managed-signer/managed-signer.service.ts
Conditionals updated to assert deploymentAllowance only when a MsgCreateDeployment is present; feeAllowance and other checks unchanged; no exported/public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant ManagedSigner as ManagedSignerService
  participant MsgInspector as Message Inspector
  participant Allowance as AllowanceValidator
  participant Chain as Akash Chain

  Client->>ManagedSigner: sign(messages, userWallet)
  ManagedSigner->>MsgInspector: contains MsgCreateDeployment?
  MsgInspector-->>ManagedSigner: yes/no

  alt contains deployment message
    ManagedSigner->>Allowance: assert deploymentAllowance > 0
  else
    Note over ManagedSigner: Skip deployment allowance check
  end

  ManagedSigner->>Allowance: assert feeAllowance >= required
  Allowance-->>ManagedSigner: validations pass/fail

  alt validations pass
    ManagedSigner->>Chain: submit signed tx
    Chain-->>ManagedSigner: tx result
  else
    ManagedSigner-->>Client: throw validation error
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Suggested reviewers

  • stalniy

Poem

A whisk of code, a hop of fate,
I check deploys—no more, no less—quite great.
For messages not building skies,
I twitch my nose and skip those ties.
Fees still counted, carrots aligned—
Signed and sent, with burrowed mind. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/deployment-allowance-check

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 1

🔭 Outside diff range comments (1)
apps/api/src/billing/services/managed-signer/managed-signer.service.ts (1)

104-106: Avoid using any in catch; prefer unknown

This violates the repo guideline for TypeScript. Change to unknown to maintain type safety without breaking usage.

-    } catch (error: any) {
+    } catch (error: unknown) {
       throw await this.chainErrorService.toAppError(error, messages);
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 070910e and b3e4b1f.

📒 Files selected for processing (1)
  • apps/api/src/billing/services/managed-signer/managed-signer.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/api/src/billing/services/managed-signer/managed-signer.service.ts
**/*.{js,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/api/src/billing/services/managed-signer/managed-signer.service.ts
🧬 Code Graph Analysis (1)
apps/api/src/billing/services/managed-signer/managed-signer.service.ts (1)
apps/indexer/drizzle/schema.ts (1)
  • message (521-567)
⏰ 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). (2)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
🔇 Additional comments (1)
apps/api/src/billing/services/managed-signer/managed-signer.service.ts (1)

74-76: Correctly scope deployment allowance check to MsgCreateDeployment

This aligns with the PR objective and prevents blocking non-deployment messages unnecessarily.

Comment on lines +74 to +76
if (messages.some(message => message.typeUrl === "/akash.deployment.v1beta3.MsgCreateDeployment")) {
assert(userWallet.deploymentAllowance > 0, 403, "UserWallet has no deployment allowance");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Use a shared constant or type guard for the typeUrl to avoid typos and future version drift

Hardcoding the string inline risks typos and makes future protocol bumps harder. Consider centralizing:

  • Define a constant (or import one if available) for "/akash.deployment.v1beta3.MsgCreateDeployment".
  • Optionally, support multiple versions if both can appear during migrations.

Example:

// e.g., constants/akash.ts
export const MSG_CREATE_DEPLOYMENT = "/akash.deployment.v1beta3.MsgCreateDeployment";
// usage
if (messages.some(m => m.typeUrl === MSG_CREATE_DEPLOYMENT)) { ... }

To confirm whether other versions of the CreateDeployment msg appear in this repo (e.g., v1beta2) and whether a shared constant already exists, run:


🏁 Script executed:

#!/bin/bash
# Find occurrences of CreateDeployment messages and potential shared constants
rg -n --no-ignore-case $'/akash\\.deployment\\..*\\.(MsgCreateDeployment)' -A 2 -B 2
rg -n --no-ignore-case $'MsgCreateDeployment' -A 2 -B 2
rg -n --no-ignore-case $'typeUrl' -A 1 -B 1 | rg -n 'CreateDeployment'

Length of output: 1609


🏁 Script executed:

#!/bin/bash
# Search for any MsgCreateDeployment typeUrl usages (all versions)
rg -n -e "/akash\.deployment\.[^/]*\.MsgCreateDeployment" -t ts

# Search for any existing constant definitions referencing CreateDeployment
rg -n -e "CREATE_DEPLOYMENT" -t ts

Length of output: 7659


Centralize MsgCreateDeployment typeUrl into a shared constant

To avoid hard-coding the same string in multiple places and ease future version bumps, introduce a single constant (and optional type-guard) for MsgCreateDeployment and replace all inline usages in the API:

• Define in a new file, e.g. apps/api/src/constants/akash.ts:

export const MSG_CREATE_DEPLOYMENT = "/akash.deployment.v1beta3.MsgCreateDeployment";
// Optional: support older versions if needed
export const MSG_CREATE_DEPLOYMENT_VERSIONS = [
  "/akash.deployment.v1beta1.MsgCreateDeployment",
  "/akash.deployment.v1beta2.MsgCreateDeployment",
  MSG_CREATE_DEPLOYMENT,
];
export function isMsgCreateDeployment(typeUrl: string): boolean {
  return MSG_CREATE_DEPLOYMENT_VERSIONS.includes(typeUrl);
}

• Replace inline checks like:

if (messages.some(m => m.typeUrl === "/akash.deployment.v1beta3.MsgCreateDeployment")) {  }

with:

import { isMsgCreateDeployment } from "constants/akash";
if (messages.some(m => isMsgCreateDeployment(m.typeUrl))) {  }

Locations to update in apps/api:

  • billing/services/managed-signer/managed-signer.service.ts (line 74)
  • billing/services/trial-validation/trial-validation.service.ts (lines 19, 29)
  • billing/services/chain-error/chain-error.service.ts (line 52)
  • billing/services/rpc-message-service/rpc-message.service.ts (line 168)
  • billing/http-schemas/tx.schema.ts (line 10)
🤖 Prompt for AI Agents
In apps/api/src/billing/services/managed-signer/managed-signer.service.ts around
lines 74-76, the MsgCreateDeployment typeUrl is hard-coded; create a new
constant file at apps/api/src/constants/akash.ts exporting MSG_CREATE_DEPLOYMENT
(and optional MSG_CREATE_DEPLOYMENT_VERSIONS and isMsgCreateDeployment helper
that checks inclusion), then replace the inline comparison with messages.some(m
=> isMsgCreateDeployment(m.typeUrl)) and update the other listed files
(trial-validation.service.ts lines 19 & 29, chain-error.service.ts line 52,
rpc-message.service.ts line 168, and billing/http-schemas/tx.schema.ts line 10)
to import and use the constant/helper instead of the literal string.

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.20%. Comparing base (070910e) to head (b3e4b1f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1804      +/-   ##
==========================================
- Coverage   42.48%   42.20%   -0.29%     
==========================================
  Files         933      928       -5     
  Lines       26292    26116     -176     
  Branches     7000     6987      -13     
==========================================
- Hits        11169    11021     -148     
+ Misses      14769    14741      -28     
  Partials      354      354              
Flag Coverage Δ *Carryforward flag
api 81.20% <100.00%> (+0.01%) ⬆️
deploy-web 20.79% <ø> (ø) Carriedforward from 070910e
log-collector ?
notifications 87.59% <ø> (ø) Carriedforward from 070910e
provider-console 81.48% <ø> (ø) Carriedforward from 070910e
provider-proxy 84.75% <ø> (ø) Carriedforward from 070910e

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
.../services/managed-signer/managed-signer.service.ts 96.82% <100.00%> (+0.05%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@baktun14 baktun14 merged commit 844ea53 into main Aug 13, 2025
62 checks passed
@baktun14 baktun14 deleted the fix/deployment-allowance-check branch August 13, 2025 15:03
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