Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(p2p): replace order in single packet #1812

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Conversation

sangaman
Copy link
Collaborator

@sangaman sangaman commented Aug 12, 2020

This modifies the procedure for replacing an order in the order book. Previously, it would go like this:

  1. Remove old order & send order invalidation to peers.
  2. Place new order and wait for matching to complete (which may take
    some time if it involves swap attempts).
  3. Send new order to peers.

Now it goes:

  1. Put the old order on hold, preventing further swaps/matching.
  2. Place the new order and wait for matching to complete.
  3. Remove the old order from the order book.
  4. Send a single packet to peers with new order info and old order id.
  5. Peers that receive this packet will remove the old order and add the new one sequentially.

By default, replaced orders will have the same local order id as the order they are replacing unless a different id is specified.

Closes #1805. Closes #1806.

@sangaman sangaman added p2p Peer to peer networking grpc gRPC API order book labels Aug 12, 2020
@sangaman sangaman requested review from a user, kilrau and raladev August 12, 2020 15:35
@sangaman sangaman self-assigned this Aug 12, 2020
@sangaman sangaman force-pushed the replace-order-packet branch 4 times, most recently from a8a91e6 to 054b763 Compare August 13, 2020 05:46
@kilrau kilrau added the P1 top priority label Aug 13, 2020
@raladev
Copy link
Contributor

raladev commented Aug 13, 2020

Commit: a3a70ac

@sangaman sangaman force-pushed the replace-order-packet branch 2 times, most recently from 035121e to 8fb68a4 Compare August 14, 2020 08:20
@sangaman sangaman marked this pull request as ready for review August 14, 2020 08:21
@sangaman
Copy link
Collaborator Author

I made several fixes and new tests, including some manual testing. I mainly just want to make sure the simulation tests here pass, since I was having some trouble running them locally. I'll check back tomorrow and make sure everything is good with the tests, but in the meantime this is ready for testing/review.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Would it be possible to use the same order id when replacing the order?

➜  xud git:(replace-order-packet) ✗ ./bin/xucli sell 0.001 BTC/USDT 10000 --order_id="abc123" no matches found
➜  xud git:(replace-order-packet) ✗ ./bin/xucli sell 0.001 BTC/USDT 13000 --replace_order_id="abc123" --order_id="abc123"
6 ALREADY_EXISTS: order with local id abc123 already exists

At the moment arby's implementation is using:

`arby-${pairId}-buy-order`
`arby-${pairId}-sell-order`;

as order ids which works against master branch, but fails in this branch.

@raladev
Copy link
Contributor

raladev commented Aug 14, 2020

  • utils matching output is still broken
    it prints nothing except of no matches found when match was founded and swap was successful
    Screen utils
    Screen log
  • replace with different ids works (~0.2 sec is required to deliver packet to remote node), but if match was founded, replace will be performed only after 20-30 sec (time of swap). So, real testing with arby is required, it can be a bottleneck.

@sangaman
Copy link
Collaborator Author

Would it be possible to use the same order id when replacing the order?

Yes I can try and handle #1806 here as well.

This modifies the procedure for replacing an order in the order book.
Previously, it would go like this:

1. Remove old order & send order invalidation to peers.
2. Place new order and wait for matching to complete (which may take
some time if it involves swap attempts).
3. Send new order to peers.

Now it goes:

1. Put the old order on hold, preventing further swaps/matching.
2. Place the new order and wait for matching to complete.
3. Remove the old order from the order book.
4. Send a single packet to peers with new order info and old order id.
5. Peers that receive this packet will remove the old order and add
the new one sequentially.

By default, replaced orders will have the same local order id as the
order they are replacing unless a different id is specified.

Closes #1805. Closes #1806.
@sangaman sangaman requested a review from a user August 14, 2020 16:10
@sangaman
Copy link
Collaborator Author

Replaced orders now use the id of the order they are replacing by default, all tests are passing, and the issue with the cli not displaying matches has been fixed. Thanks!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Works nicely - good job 👍

Tested with arby's ExchangeUnion/market-maker-bot#75 branch

@raladev raladev merged commit de691b2 into master Aug 17, 2020
@sangaman sangaman deleted the replace-order-packet branch August 24, 2020 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grpc gRPC API order book P1 top priority p2p Peer to peer networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace order call should issue new order with *same id* by default Replace order call should be atomic
3 participants