Race condition in using ManageOffer operation to modify an offer

Open
#181 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale

Research direction

Start with the ManageOffer operation and its amount field, then compare the issue's race-condition scenario with the cited Nasdaq OUCH specification. Done means the protocol clearly defines an atomic offer modification that updates total liability rather than only the currently unfilled amount, preventing the described over-sale.

Written by the indexing model from the issue text.

Description

bug CAP help wanted needs draft

When using the ManageOffer operation to update an offer, the amount field replaces the currently available (unfilled) amount on the offer, rather than replacing the total liability specified when the offer was made. This leads to the following behavior:

Person A: Submit transaction 1: Sell 100 Marbles @ X1
Network processes transaction 1.
Person B: Submit transaction 2: Buy 90 Marbles @ X1
Person A: Submit transaction 3: Change offer to Sell 100 Marbles @ X2
Person C: Submit transaction 4: Buy 100 Marbles @ X2
Network processes transactions 2,3,4

At the end of this, Person A has sold 190 Marbles because of the race condition, whereas he intended to only sell 100 but update his price.

Pretty much all financial markets allow for atomic changes to orders, but its always very clear in the specs that it updates the total liability, not the outstanding liability, specifically because of the race condition with in-flight messages. For example, Nasdaq's proprietary specification states the following for the quantity field: "Total number of shares liable, inclusive of previous executions and Self Match Prevention decremented shares on this order chain"

Dominant language
RPC
Stars
632
Forks
399
Avg merge
1d 23h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-protocol

All issues in stellar/stellar-protocol

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.