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

multi: update dex client #633

Merged
merged 9 commits into from
Sep 25, 2024

Conversation

ukane-philemon
Copy link
Collaborator

Closes #632

@ukane-philemon
Copy link
Collaborator Author

ukane-philemon commented Sep 6, 2024

I've noticed a few issues that I'm unable to resolve atm:

  1. The server and market selection on the dex market page no longer stack on top of every element on the page when the dropdown is expanded
  2. The dex market page doesn't scroll downwards unless the scrollbar is used (noticed the same thing on the post bond step).
  3. The order type selection on the order form should be directly under the order type collapsed view.

I think these issues arose after recent dropdown code changes and the gioui version update.

@bugjt
Copy link
Collaborator

bugjt commented Sep 7, 2024

I have solved it

I've noticed a few issues that I'm unable to resolve atm:

  1. The server and market selection on the dex market page no longer stack on top of every element on the page when the dropdown is expanded
  2. The dex market page doesn't scroll downwards unless the scrollbar is used (noticed the same thing on the post bond step).
  3. The order type selection on the order form should be directly under the order type collapsed view.

I think these issues arose after recent dropdown code changes and the gioui version update.

@ukane-philemon
Copy link
Collaborator Author

#633 (comment) has been resolved by 756a6cf

Copy link
Collaborator

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

Trading is not working on dextest, I'll look into why not.

Edit, I found the logs, and trading is working I forgot to build with an adjusted locktime

@JoeGruffins
Copy link
Collaborator

JoeGruffins commented Sep 19, 2024

There aren't many logs, are the dex ones spitting out somewhere?

The LTC logs are very loud though:

2024-09-19 16:52:17.502 [INF] LTC: Attempting to fetch set of un-checkpointed filters at height=808, hash=fe01b65a007e4b8f3056891fe4bb81e136fee1cd9b9173efa7f7628ddb69bd4d
2024-09-19 16:52:17.503 [INF] LTC: Verified 1 filter header in the last 15.01s (height 808, 2024-09-19 16:52:17 +0900 JST)
2024-09-19 16:52:32.513 [INF] LTC: Processed 1 block in the last 15.01s (height 809, 2024-09-19 16:52:32 +0900 JST)

@JoeGruffins
Copy link
Collaborator

JoeGruffins commented Sep 19, 2024

Seeing some weird stuff with bonds. It's spinning somewhere:

2024-09-19 08:31:58.934 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.934 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.945 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.957 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.973 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.974 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.974 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)

@ukane-philemon
Copy link
Collaborator Author

Seeing some weird stuff with bonds. It's spinning somewhere:

2024-09-19 08:31:58.934 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.934 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.945 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.946 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.957 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.958 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.973 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.974 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)
2024-09-19 08:31:58.974 [DBG] DEXC: Soon to expire bond found: acec8ef3f7b76c10742240bbbd02b5120e813e0b2a60aa4ee4a08d38f2c329d9:0 (dcr)

I've investigated this.

dcrdex checks for bond rotation every bondTickInterval (20 secs) in watchBonds and continues to log this until an okay bond has been posted. See: watchBonds -> bondStateOfDex -> where the log actually happens

Same thing happens when a newly expired bond is found.

@JoeGruffins
Copy link
Collaborator

JoeGruffins commented Sep 24, 2024

dcrdex checks for bond rotation every bondTickInterval (20 secs)

In my logs its logging 4 times per millisecond. It should only be once every 20 seconds correct?

@JoeGruffins
Copy link
Collaborator

More odd logging, bot the number of times in a millisecond it happens and why it needs usdc.eth:

2024-09-24 06:16:15.007 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.007 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.007 [ERR] DEXC: couldn't find minimum lot size for usdt.eth
2024-09-24 06:16:15.007 [ERR] DEXC: couldn't find minimum lot size for usdt.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdt.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdt.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdc.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdt.eth
2024-09-24 06:16:15.008 [ERR] DEXC: couldn't find minimum lot size for usdt.eth

@JoeGruffins
Copy link
Collaborator

I put in some prints and it looks like func (pg *DEXMarketPage) exchange() *core.Exchange is being hit many times per millisecond. I guess this calls exchangeInfo on the client which is a pretty heavy operation. Can you cache this info maybe? The fact that it needs that info so often is also pretty suspicious.

@ukane-philemon
Copy link
Collaborator Author

. it looks like func (pg *DEXMarketPage) exchange() *core.Exchange is being hit many times per millisecond

Aha, thanks. that's the other place bondStateOfDex is being called causing the spamming logs.

Signed-off-by: Philemon Ukane <[email protected]>
@JoeGruffins
Copy link
Collaborator

It looks like something else is still being hammered:

2024-09-25 04:44:16.196 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.340 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.345 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.359 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.373 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.401 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.425 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.453 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.453 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.479 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.863 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.870 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr
2024-09-25 04:44:16.907 [TRC] DEXC: wallet status requested for unknown asset 42 -> dcr

@JoeGruffins
Copy link
Collaborator

JoeGruffins commented Sep 25, 2024

When I navigate to the dex onboarding page, it calls func (pg *DEXOnboarding) bondAmountInfoDisplay(gtx C) D and func (pg *DEXOnboarding) bondAccountHasEnough() bool about 30 times instantly. Do you know why? Is that just how it is? Seems like resources are being wasted. I guess because The logic is inside the view constructors? Is this correct?

Seems it should calculate everything once and then use pointers to the results. Like, its's calculating the same bond amount 30 times here:

func (pg *DEXOnboarding) bondAmountInfoDisplay(gtx C) D {
	asset := pg.bondSourceWalletSelector.SelectedWallet()
	assetType := asset.GetAssetType()
	icon := pg.Theme.AssetIcon(assetType)
	bondAsset := pg.bondServer.bondAssets[assetType]
	bondsFeeBuffer := pg.AssetsManager.DexClient().BondsFeeBuffer(bondAsset.ID)
	return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
		layout.Rigid(func(gtx C) D {
			if icon == nil {
				return D{}
			}
			return layout.Inset{Right: 5}.Layout(gtx, icon.Layout20dp)
		}),
		layout.Rigid(pg.Theme.Label(values.TextSize16, calculateBondAmount(asset, bondAsset, pg.newTier, bondsFeeBuffer)).Layout),
	)
}

Copy link
Collaborator

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

I think there's lots of room for optimizing code but otherwise I think it looks good. Can optimize now or later.

Signed-off-by: Philemon Ukane <[email protected]>
@dreacot dreacot merged commit 0493db9 into crypto-power:master Sep 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dcrdex: Update client version.
5 participants