Skip to content

Commit

Permalink
Reduce log level of exceptions in order_cancel_op
Browse files Browse the repository at this point in the history
Some bots place limit orders then try to cancel some of them before a new
block arrives. However, the order's id (in pending state) may be different
in individual nodes, thus caused the exceptions.

A potential solution to the order_id inconsistent issue:
#556
  • Loading branch information
abitmore committed Jul 27, 2019
1 parent c52eb62 commit 2fc099d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion libraries/chain/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ namespace graphene { namespace chain {
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( kill_unfilled, limit_order_create, 1,
"Killing limit order due to unable to fill" )

//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel );
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_cancel, 1, "Order does not exist" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_cancel, 2, "Order owned by someone else" )

GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( call_order_update );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1, "Updating call order would trigger a margin call that cannot be fully filled" )

Expand Down
5 changes: 4 additions & 1 deletion libraries/chain/include/graphene/chain/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ namespace graphene { namespace chain {
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( limit_order_create );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( kill_unfilled, limit_order_create, 1, )

//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( limit_order_cancel );
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( limit_order_cancel );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( nonexist_order, limit_order_cancel, 1, )
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( owner_mismatch, limit_order_cancel, 2, )

GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( call_order_update );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1, "Updating call order would trigger a margin call that cannot be fully filled" )

Expand Down
13 changes: 11 additions & 2 deletions libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ void_result limit_order_cancel_evaluator::do_evaluate(const limit_order_cancel_o
{ try {
database& d = db();

_order = &o.order(d);
FC_ASSERT( _order->seller == o.fee_paying_account );
_order = d.find( o.order );

GRAPHENE_ASSERT( _order != nullptr,
limit_order_cancel_nonexist_order,
"Limit order ${oid} does not exist",
("oid", o.order) );

GRAPHENE_ASSERT( _order->seller == o.fee_paying_account,
limit_order_cancel_owner_mismatch,
"Limit order ${oid} is owned by someone else",
("oid", o.order) );

return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }
Expand Down
2 changes: 2 additions & 0 deletions libraries/net/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3409,6 +3409,8 @@ namespace graphene { namespace net { namespace detail {
// log common exceptions in debug level
case 3030001: // duplicate_transaction
case 3050101: // limit_order_create_kill_unfilled
case 3050201: // limit_order_cancel_nonexist_order
case 3050202: // limit_order_cancel_owner_mismatch
dlog( "client rejected message sent by peer ${peer}, ${e}",
("peer", originating_peer->get_remote_endpoint() )("e", e) );
break;
Expand Down

0 comments on commit 2fc099d

Please sign in to comment.