Skip to content

improvement(best-orders): return an rpc error when we can't find best orders #2318

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

Merged
merged 8 commits into from
Apr 4, 2025

Conversation

mariocynicys
Copy link
Collaborator

Return an RPC error in best orders rpc if we were not able to get the best orders because nobody in the network replied to our p2p request.
This is saner that returning a successful result with no best orders inside.

Kinda addresses #2228

@mariocynicys
Copy link
Collaborator Author

in progress since i will check also other p2p interacting RPCs and apply the same patch to.
p2p interactions aren't guaranteed to succeed, so we should make that obvious/visible from the RPC side.

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

Since it's been a month, can you share the status quo of this PR?

Changes seem harmless, so the current status is also LGTM.

@mariocynicys
Copy link
Collaborator Author

@onur-ozkan there is one last place we ask for any peer's response but we don't error.
i opted for not erroring here since part of the response is computed from local data and isn't completely dependent p2p network.

@shamardy shamardy self-requested a review February 17, 2025 10:08
@onur-ozkan
Copy link
Member

onur-ozkan commented Feb 19, 2025

Please ping me once this is on "pending review" status.

@mariocynicys
Copy link
Collaborator Author

ping @onur-ozkan :)

@mariocynicys
Copy link
Collaborator Author

mariocynicys commented Feb 21, 2025

some tests are failing now because when a single seed node in a network does orderbook request it must fail (no other seed node to reply).
I am not sure whether it's better to adjust for this case in test environment or revert the last commit all together? (or maybe never error for seednodes p2p requests. as the nicer UX this PR brings is targeted for users anyway).

@shamardy shamardy requested review from shamardy and removed request for shamardy March 3, 2025 11:52
onur-ozkan
onur-ozkan previously approved these changes Mar 4, 2025
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

LGTM.

Just to make sure, when remote peers return no data, will we still be able to return an empty list as a response?

@mariocynicys
Copy link
Collaborator Author

Just to make sure, when remote peers return no data, will we still be able to return an empty list as a response?

yup, a no data (i.e. empty vector/set) response is a valid response.

@onur-ozkan
Copy link
Member

Can you pull dev branch to this PR, test pipelines are so red right now.

@shamardy
Copy link
Collaborator

shamardy commented Mar 5, 2025

I am not sure whether it's better to adjust for this case in test environment or revert the last commit all together? (or maybe never error for seednodes p2p requests. as the nicer UX this brings is targeted for users anyway).

If the local node is a seed node, we should never return an error, as it has already subscribed to all topics and possesses the order book. It should still request and fill the order book in case it doesn't have the latest state or just came online, but if no other seeds respond, we should return the local copy of the order book. For test cases you mentioned, we should run this single node as a seed node. We will still get this issue #2228 with seednodes, but it's a GUI issue so not a problem. What do you think @mariocynicys ?

@shamardy
Copy link
Collaborator

shamardy commented Mar 5, 2025

don't forget to pull the latest commit @mariocynicys, I wanted to see which tests were failing

@mariocynicys
Copy link
Collaborator Author

If the local node is a seed node, we should never return an error,

agreed.

@dimxy
Copy link
Collaborator

dimxy commented Mar 10, 2025

Some tests now return the new errors like No response received from any peer for GetOrderbook request.
Maybe we should add a #[cfg(not(for-tests))] or #[cfg(not(run-docker-tests))] condition for those errors?

@dimxy
Copy link
Collaborator

dimxy commented Mar 10, 2025

looks like here in orderbook_depth_rpc we also may want to return an error, if no peer responded with some data?

@mariocynicys
Copy link
Collaborator Author

Some tests now return the new errors like No response received from any peer for GetOrderbook request.
Maybe we should add a #[cfg(not(for-tests))] or #[cfg(not(run-docker-tests))] condition for those errors?

Yup, these are from a single (seed) node network test. Will have seed nodes never error all together since they should have all the data stored already.

looks like here in orderbook_depth_rpc we also may want to return an error, if no peer responded with some data?

refer to #2318 (comment). I am not sure though about whether this reasoning is good enough. So would be nice to have more inputs/opinions.

@dimxy
Copy link
Collaborator

dimxy commented Mar 14, 2025

As I can see in the code,
for the orderbook rpc returning this error gives a hint that the User may retry initial sync of the orderbook within 60 sec,
but after 60 sec he won't be getting the error (even if still not connected to peers).
I would agree this is better that now

shamardy
shamardy previously approved these changes Apr 1, 2025
for the seed node case. non-seed nodes will error instead
@shamardy shamardy merged commit 62acce7 into dev Apr 4, 2025
24 checks passed
@shamardy shamardy deleted the best-orders-warmup branch April 4, 2025 12:46
dimxy added a commit that referenced this pull request Apr 7, 2025
* dev:
  improvement(best-orders): return an rpc error when we can't find best orders (#2318)
  feat(utxo): support FIRO Spark verbose tx
  feat(ARRR): dockerize zombie/pirate tests  (#2374)
  improvement(event-streaming): move UnknownClient error to trace level (#2401)
  feat(tpu): implement 0 dexfee for kmd trading pairs (#2323)
  feat(db-arch): ctx functions and use of global db (#2378)
  feat(swap): add utxo/cosmos/ARRR pre-burn address output (#2112)
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request May 13, 2025
* dev: (26 commits)
  chore(deps): remove base58 and replace it completely with bs58 (KomodoPlatform#2427)
  feat(tron): initial groundwork for full TRON integration (KomodoPlatform#2425)
  fix(UTXO): improve tx fee calculation and min relay fee handling (KomodoPlatform#2316)
  deps(timed-map): bump to 1.3.1 (KomodoPlatform#2413)
  improvement(tendermint): safer IBC channel handler (KomodoPlatform#2298)
  chore(release): complete v2.4.0-beta changelogs  (KomodoPlatform#2436)
  fix(event-streaming): initial addresses registration in utxo balance streaming (KomodoPlatform#2431)
  improvement(watchers): re-write use-watchers handling (KomodoPlatform#2430)
  fix(evm): make withdraw_nft work in HD mode (KomodoPlatform#2424)
  feat(taproot): support parsing taproot output address types
  chore(RPC): use consistent param name for QTUM delegation (KomodoPlatform#2419)
  fix(makerbot): add LiveCoinWatch price provider (KomodoPlatform#2416)
  chore(release): add changelog entries for v2.4.0-beta (KomodoPlatform#2415)
  fix(wallets): prevent path traversal in `wallet_file_path` and update file extension (KomodoPlatform#2400)
  fix(nft): make `update_nft` work with hd wallets using the enabled address (KomodoPlatform#2386)
  fix(wasm): unify error handling for mm2_main (KomodoPlatform#2389)
  fix(tx-history): token information and query (KomodoPlatform#2404)
  test(electrums): fix failing test_one_unavailable_electrum_proto_version (KomodoPlatform#2412)
  improvement(network): remove static IPs from seed lists (KomodoPlatform#2407)
  improvement(best-orders): return an rpc error when we can't find best orders (KomodoPlatform#2318)
  ...
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request May 27, 2025
* lr-swap-wip: (45 commits)
  review (mariocynicys): fix iterators zipping, refactor 1inch url builder, add docs to cross prices data, remove extra coin decimals check
  added doc comments for LrData struct
  error msg improved
  fix tx value eth conversion
  eliminate from_api_error fn
  fix src_decimals var name
  improve bad api TokenInfo error messages
  improvement(best-orders): return an rpc error when we can't find best orders (KomodoPlatform#2318)
  feat(utxo): support FIRO Spark verbose tx
  feat(ARRR): dockerize zombie/pirate tests  (KomodoPlatform#2374)
  improvement(event-streaming): move UnknownClient error to trace level (KomodoPlatform#2401)
  feat(tpu): implement 0 dexfee for kmd trading pairs (KomodoPlatform#2323)
  feat(db-arch): ctx functions and use of global db (KomodoPlatform#2378)
  feat(swap): add utxo/cosmos/ARRR pre-burn address output (KomodoPlatform#2112)
  review (laruh): rename fn
  review (laruh): add fn to get contracts from LrData
  add TODO
  fix find best lr swap behaviour: skip lr provider error results (to use successful ones)
  refactor 1inch url builder
  fix 1inch result conversion test
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants