decred / dcrdex

The Decred Decentralized Exchange (DEX), powered by atomic-swaps.
Other
184 stars 91 forks source link

with an active order, fee rates are requested each epoch #1718

Closed chappjc closed 2 years ago

chappjc commented 2 years ago
2022-07-18 16:46:22.678 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:46:30.177 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:46:37.677 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:46:45.177 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:46:52.677 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:47:00.177 [DBG] CORE[dcr]: Retrieving fee rate from external API
2022-07-18 16:47:07.677 [DBG] CORE[dcr]: Retrieving fee rate from external API

The feeRate method in the above come from:

decred.org/dcrdex/client/asset/dcr.(*ExchangeWallet).FeeRate(0xc0002d97a0)
    /home/jon/github/decred/dcrdex/client/asset/dcr/dcr.go:878 +0x27
decred.org/dcrdex/client/core.(*Core).cacheRedemptionFeeSuggestion(0xc000322000, 0xc000170000)
    /home/jon/github/decred/dcrdex/client/core/core.go:7013 +0x53
decred.org/dcrdex/client/core.(*Core).tick(0xc000322000, 0xc000170000)
    /home/jon/github/decred/dcrdex/client/core/trade.go:1348 +0x189
decred.org/dcrdex/client/core.(*Core).listen.func3()
    /home/jon/github/decred/dcrdex/client/core/core.go:6476 +0x88a
decred.org/dcrdex/client/core.(*Core).listen.func4()
    /home/jon/github/decred/dcrdex/client/core/core.go:6506 +0x234
created by decred.org/dcrdex/client/core.(*Core).listen
    /home/jon/github/decred/dcrdex/client/core/core.go:6491 +0x3d0

I don't recall why, but cacheRedemptionFeeSuggestion calls the FeeRate method if the wallet is a FeeRater. If the wallet is a FeeRater, why does Core need to cache it's own suggestion? The issue seems to be in redeemMatchGroup where it atomic loads t.redeemFeeSuggestion but does not call FeeRate at all. We understandably want to avoid requesting fee rates in redeemMatchGroup, esp. if they are from remote sources, but we cannot call FeeRate on the ticker like we are doing now.

chappjc commented 2 years ago

Pursuing a resolution to this issue and https://github.com/decred/dcrdex/issues/1717. Rough plan, subject to change as I feel out the issues more:

chappjc commented 2 years ago

Resolution in https://github.com/decred/dcrdex/pull/1721

chappjc commented 2 years ago

Resolved by https://github.com/decred/dcrdex/pull/1721