Skip to content

Market: fix losing bids stuck open after lease #441

@Zblocker64

Description

@Zblocker64

Market: losing bids stuck BID_OPEN after lease creation

Describe the bug

When a lease is created for one bid on an order, other providers’ bids on that same order can stay BID_OPEN on chain with bid escrow still open, even though MsgCreateLease completes successfully (code 0).

Root cause

  1. Escrow onAccountClosed hooks ran for all escrow scopes. The market module registers OnEscrowAccountClosed, which treats the account ID as a deployment escrow and calls DeploymentIDFromEscrowID. That fails for ScopeBid (bid escrows). The hook error bubbled up and AccountClose failed for losing bids during lease creation.

  2. The CreateLease loser loop stopped early on that error. The WithBidsForOrder callback return true when AccountClose failed, which ends iteration and skips remaining open bids. Those bids were never marked lost and their escrows were never closed.

Fix

  • In x/escrow/keeper, invoke onAccountClosed hooks only when obj.ID.Scope == ScopeDeployment (bid and other scopes skip hooks; AccountClose can complete).

  • In x/market/handler CreateLease, do not return true on AccountClose failure; log and return false so every other BID_OPEN bid on the order is still processed.


To reproduce

  1. Create a deployment and an order; have at least two providers place open bids on the same order (same dseq / gseq / oseq).

  2. Create a lease for one of those bids (akash tx market lease create … or equivalent).

  3. Query the other provider’s bid, e.g. akash query market bid get ….

Observed (bug): That bid can remain state: open with bid escrow still open, while the winning bid is active and the lease exists.

Reproduction is deterministic when the pre-fix code runs bid AccountClose through deployment-only hooks and the loser callback stops after the first failure.


Expected behavior

After a successful MsgCreateLease:

  • Every other open bid on that order is BID_LOST.
  • Each losing bid’s bid escrow is closed (normal return of bid deposit / settlement path).
  • The winner remains BID_ACTIVE with bid escrow behavior unchanged for the lease.

Additional context (optional)

  • Area: x/escrow/keeper (saveAccount), x/market/handler/server.go (CreateLease loser loop).
  • Network: Consensus / state-machine change; coordinated node release required.

Metadata

Metadata

Assignees

Labels

repo/nodeAkash node repo issues

Type

No type

Projects

Status

Backlog (not prioritized)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions