Skip to content

Order fill events notified before order creation events #1277

@abitmore

Description

@abitmore

Bug Description

the market subscription thread seems to be guaranteed to fire before the transaction callback thread, which doesn't make sense for clients because it implies that the market order went through before it actually did.

A client that subscribed to a market always receives order fill events before order creation events if the orders are partially filled in a same block. Note: no notification on order creation if it gets completely filled in same block (not sure if it need to be fixed so far).

There is a FIXME in code:

if( market.valid() && _market_subscriptions.count(*market) )
// FIXME this may cause fill_order_operation be pushed before order creation
subscribed_markets_ops[*market].emplace_back( std::move( std::make_pair( op.op, op.result ) ) );

Probably because on_applied_block() is called before on_objects_changed():

// notify observers that the block has been applied
notify_applied_block( next_block ); //emit
_applied_ops.clear();
notify_changed_objects();

Expected Behavior
When a new order is placed, clients receive an order creation event first, then an order fill event.

Additional Context (optional)
I'm not sure if it's safe to simply move on_objects_changed() to be called before on_applied_block().

Impacts
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.

  • API (the application programming interface)
  • Build (the build process or something prior to compiled code)
  • CLI (the command line wallet)
  • Deployment (the deployment process after building such as Docker, Travis, etc.)
  • DEX (the Decentralized EXchange, market engine, etc.)
  • P2P (the peer-to-peer network for transaction/block propagation)
  • Performance (system or user efficiency, etc.)
  • Protocol (the blockchain logic, consensus, validation, etc.)
  • Security (the security of system or user data, etc.)
  • UX (the User Experience)
  • Other (please add below)

CORE TEAM TASK LIST

  • Evaluate / Prioritize Bug Report
  • Refine User Stories / Requirements
  • Define Test Cases
  • Design / Develop Solution
  • Perform QA/Testing
  • Update Documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    2a Discussion NeededPrompt for team to discuss at next stand up.3d BugClassification indicating the existing implementation does not match the intention of the design4b Normal PriorityPriority indicating the moderate impact to system/user -OR- existing workaround is costly to perform6 APIImpact flag identifying the application programing interface (API)bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions