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

loadbot: Allow use with all markets. #1656

Merged
merged 1 commit into from Jun 20, 2022

Conversation

JoeGruffins
Copy link
Member

closes #1565

@chappjc
Copy link
Member

chappjc commented Jun 10, 2022

Let's update loadbot's go.mod

module decred.org/dcrdex/dex/testing/loadbot

go 1.17

// go mod tidy while commented:
// replace decred.org/dcrdex => ../../../

require (
	decred.org/dcrdex v0.0.0-20220609033337-f9b5b4ccdfac
	github.com/Shopify/toxiproxy/v2 v2.4.0
)

go mod tidy -go=1.16 && go mod tidy -go=1.17

Just need to update the toxiproxy import path:

diff --git a/dex/testing/loadbot/loadbot.go b/dex/testing/loadbot/loadbot.go
index 2032fd2b..7f65966c 100644
--- a/dex/testing/loadbot/loadbot.go
+++ b/dex/testing/loadbot/loadbot.go
@@ -32,7 +32,7 @@ import (
        "decred.org/dcrdex/dex/config"
        dexbtc "decred.org/dcrdex/dex/networks/btc"
        dexsrv "decred.org/dcrdex/server/dex"
-       toxiproxy "github.com/Shopify/toxiproxy/client"
+       toxiproxy "github.com/Shopify/toxiproxy/v2/client"
 )

@JoeGruffins JoeGruffins force-pushed the loadbototherassets branch 4 times, most recently from 557e9a9 to b8a8778 Compare June 15, 2022 11:59
@JoeGruffins JoeGruffins marked this pull request as ready for review June 15, 2022 12:00
@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 15, 2022

Working mostly for all coins. Some amounts still need to be adjusted, but I'm unsure of what's best. I think they can be adjusted as others see fit. For example, the heavy suite needs lots of funds that some harnesses do not have enough of.

The Zec compound tests fails with:

2022-06-15 21:03:38.573 [ERR] LOADBOT: exec error (zec) "./alpha": exit status 4: error code: -4
error message:
Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of the wallet and coins were spent in the copy but not marked as spent here.

All compound suites involving dcr seem to fail with this eventually:

2022-06-15 20:40:41.371 [CRT] MANTLE:CMPD:STACKER:0: Error note received: {"type":"order","topic":"ReportRedeemError","subject":"Redeem reporting error","details":"Error notifying DEX of redemption for match 191411ecd922b23c003031a953fad008510c45290c4dfb381483c648a86178ae: error sending 'redeem' message: timed out waiting for \"redeem\" response","severity":5,"stamp":1655293241370,"acked":false,"id":"2325ea84f02ecc10","order":{"host":"127.0.0.1:17273","baseID":42,"baseSymbol":"dcr","quoteID":0,"quoteSymbol":"btc","market":"dcr_btc","type":1,"id":"3f84790cdc281dd8022081c36216580dac60314a5f4af1c94d3c55a5df28b073","stamp":1655293098911,"sig":"3045022100afc0a15cee1dc1619f3f7f432d52372586515e5148838ce4cfd8a0efc91c5c1402205f25ff00c360c016d39d718d50eba762ffa079101cb2d6152aae9428bdd2ce92","status":3,"epoch":110352873,"qty":9000000000,"sell":true,"filled":9000000000,"matches":[{"matchID":"191411ecd922b23c003031a953fad008510c45290c4dfb381483c648a86178ae","status":3,"active":false,"revoked":true,"rate":96600,"qty":6000000000,"side":0,"feeRate":10,"swap":{"id":"d7d55a9e238d0cfd05886fb040d57e0140d382a98cd89a6da65903b55bb9740a00000000","stringID":"0a74b95bb50359a66d9ad88ca982d340017ed540b06f8805fd0c8d239e5ad5d7:0","assetID":42,"symbol":"dcr"},"counterSwap":{"id":"76063548e54bee65f8e3678e0a58ff4ddf967db579b7f1388b985ec53bdabeb800000000","stringID":"b8beda3bc55e988b38f1b779b57d96df4dff580a8e67e3f865ee4be548350676:0","assetID":0,"symbol":"btc"},"redeem":{"id":"594496723fb9e309cde37781b45de9922ce2068d3ab3725913adec3a5f54882400000000","stringID":"2488545f3aecad135972b33a8d06e22c92e95db48177e3cd09e3b93f72964459:0","assetID":0,"symbol":"btc"},"stamp":1655293140000,"isCancel":false},{"matchID":"3c100d3ac61e20d03cbf4f1f5e7a22e437cba91e26116177f2490e3205ea16f8","status":3,"active":true,"revoked":false,"rate":96600,"qty":3000000000,"side":0,"feeRate":10,"swap":{"id":"9c4464fdb63b7ea13d4763f7967f962307a28cc23b500bd3848a83271c8c5db400000000","stringID":"b45d8c1c27838a84d30b503bc28ca20723967f96f763473da17e3bb6fd64449c:0","assetID":42,"symbol":"dcr"},"counterSwap":{"id":"c0a217da04ef01c00dc2d9c8b18342fd628f0571fffdbcc2dfeda59815506eb700000002","stringID":"b76e501598a5eddfc2bcfdff71058f62fd4283b1c8d9c20dc001ef04da17a2c0:2","assetID":0,"symbol":"btc"},"redeem":{"id":"8d3ccee98c9b412150dddec33ec82aa95ead5a36a3882676ebf7f61ef0945d4300000000","stringID":"435d94f01ef6f7eb762688a3365aad5ea92ac83ec3dedd5021419b8ce9ce3c8d:0","assetID":0,"symbol":"btc"},"stamp":1655293155000,"isCancel":false}],"cancelling":false,"canceled":false,"feesPaid":{"swap":4990,"redemption":286},"fundingCoins":[{"id":"11288f3c24c34fb2a1cb29660ba4634af38a12b36df44cfeada1e7b40374e3a900000001","stringID":"a9e37403b4e7a1adfe4cf46db3128af34a63a40b6629cba1b24fc3243c8f2811:1","assetID":42,"symbol":"dcr"}],"lockedamt":0,"accelerationCoins":[],"rate":96600,"tif":1,"targetOrderID":""}}

Other than that I think this pr solves the issue.

dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
dex/testing/loadbot/loadbot.go Outdated Show resolved Hide resolved
dex/testing/loadbot/mantle.go Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
dex/testing/loadbot/loadbot.go Outdated Show resolved Hide resolved
dex/testing/loadbot/compound.go Outdated Show resolved Hide resolved
dex/testing/loadbot/compound.go Outdated Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
@chappjc
Copy link
Member

chappjc commented Jun 15, 2022

The Zec compound tests fails with:

2022-06-15 21:03:38.573 [ERR] LOADBOT: exec error (zec) "./alpha": exit status 4: error code: -4
error message:
Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of the wallet and coins were spent in the copy but not marked as spent here.

Hmm, I guess that ./alpha command it was trying to run was sending funds to the wallet to fund more orders?

Could this relate to restrictions in spending coinbase outputs? zcash/zcash#1431
zcash/zcash#1373

@JoeGruffins
Copy link
Member Author

Just rebased.

@JoeGruffins
Copy link
Member Author

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 16, 2022

Could this relate to restrictions in spending coinbase outputs?

It looks like the issue is fixed in that pr? Maybe just trying to send to many coins too fast? I don't see this with just the pingpong suite.

I did see this with the pingpong however:

2022-06-16 17:56:39.495 [CRT] MANTLE:PINGPONG:0: Trade error (limit order, sell = true, qty = 100000000, rate = 878000): new order request with DEX server 127.0.0.1:17273 market zec_btc failed: rpc error: error code 24: failed to find funding coins [cda1117a5496b8cfdb762570962341f58b6fdfe673d4e0d74be7d8c72bd63053:0]

pingpong is mostly fine it seems.

@@ -219,12 +219,6 @@ tmux kill-session
EOF
chmod +x "${NODES_ROOT}/harness-ctl/quit"

cat > "${NODES_ROOT}/harness-ctl/new-wallet" <<EOF
Copy link
Member

Choose a reason for hiding this comment

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

Everyone OK with losing the new-wallet shell script? Personally I use the general node wrapper directly like ./alpha createwallet, so it's fine with me.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like that's what @JoeGruffins is doing now in loadbot, so we can lose it, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Right, I meant for tooling around in the harness control tmux.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was only one rpc call, so I didn't think it had a good purpose for the coins it existed in. The new start-wallet script has a lot of set-up so I sorta moved this there for places where I thought it was needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Although, the btc create ended up really long because I needed to put in a lot of args to turn descriptor wallets off. Maybe I should put it back for more visibility in the harness whenever they change and become use-able. I see some prs about them.

Copy link
Member

Choose a reason for hiding this comment

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

Meh I think we can live without new-wallet.
Descriptor wallets are going to be fine really soon anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

I added it back for btc, bch, and litecoin and think it's useful... Can remove again tho.

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

Working well for me.

dex/testing/loadbot/loadbot.go Outdated Show resolved Hide resolved
Copy link
Contributor

@martonp martonp left a comment

Choose a reason for hiding this comment

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

Just some very minor nits. I hadn't looked at the loadbot before.. we should add support for each of the different wallet types as well.

dex/testing/loadbot/mantle.go Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
dex/testing/loadbot/mantle.go Outdated Show resolved Hide resolved
@JoeGruffins
Copy link
Member Author

Added back new-wallet for bitcoin assets and added info to the markets error. https://github.com/decred/dcrdex/compare/67190d7e42b1b1ba647c28f3894f2db53eef13e9..04faf33b6b728330d8afc15ee9bbf28402c2b73b

@JoeGruffins
Copy link
Member Author

@chappjc chappjc added this to the 0.5 milestone Jun 17, 2022
Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

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

This is great. Just the one request.

Comment on lines 242 to 272
func nextAddr() (string, string) {
port := strconv.Itoa(int(atomic.AddUint32(&portCounter, 1) + startPort))
port := strconv.Itoa(int(atomic.AddUint32(&atomicPort, 1)))
return "127.0.0.1:" + port, port
}
Copy link
Member

Choose a reason for hiding this comment

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

Since we don't care what these ports are, something I've been playing with to prevent any chance of running into an in-use port is

func findOpenAddrs(n int) ([]net.Addr, error) {
	addrs := make([]net.Addr, 0, n)
	for i := 0; i < n; i++ {
		addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
		if err != nil {
			return nil, err
		}

		l, err := net.ListenTCP("tcp", addr)
		if err != nil {
			return nil, err
		}
		defer l.Close()
		addrs = append(addrs, l.Addr())
	}

	return addrs, nil
}

This might actually become important if we ever want to run > 1 instance of loadbot simultaneously.

Copy link
Member

Choose a reason for hiding this comment

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

Seems useful to do. There's still a race there after l.Close that the system will give it away, but it's way better than nothing.

@JoeGruffins
Copy link
Member Author

Just rebased.

@JoeGruffins
Copy link
Member Author

Saw this for the first time on dcr_doge: 2022-06-20 14:13:19.230 [CRT] MANTLE:CMPD:STACKER:1: Trade error (limit order, sell = false, qty = 200000000, rate = 922000000): new order request with DEX server 127.0.0.1:17273 market dcr_doge failed: rpc error: error code 34: order failed validation

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 20, 2022

And:

2022-06-20 14:18:00.393 [ERR] CORE:CMPD:STACKER:1: Route 'match' request handler error (DEX 127.0.0.1:17273): runMatches - {tick of order 8120c9303f488661360b45c82534462cab40864979094e64e26adbb6d6330ff4 failed: 127.0.0.1:17273 tick: {swapMatches order 8120c9303f488661360b45c82534462cab40864979094e64e26adbb6d6330ff4 - {error sending swap transaction: signing error: signing incomplete. 1 signing errors encountered: Input not found or already spent, raw tx: 0100000001926539219f312558a086d90243913405ba0013ad04a5bbfd67ab858764a9d09e0300000000ffffffff0180fc05690000000017a914368370b05df42c2dad63e4a54796f21c6d2ba9ce8700000000}}}

...

2022-06-20 14:18:00.556 [CRT] MANTLE:CMPD:STACKER:1: Error note received: {"type":"order","topic":"SwapSendError","subject":"Swap send error","details":"Error encountered sending a swap output(s) worth 17.62000000 DOGE on order 8120c930","severity":5,"stamp":1655702280334,"acked":false,"id":"b435666548fbc052","order":{"host":"127.0.0.1:17273","baseID":42,"baseSymbol":"dcr","quoteID":3,"quoteSymbol":"doge","market":"dcr_doge","type":1,"id":"8120c9303f488661360b45c82534462cab40864979094e64e26adbb6d6330ff4","stamp":1655702239446,"sig":"3044022011979a725982a19ecbe4514ad8b7e21410c68a597fa53315216d799b30f45f0b02201c3aad4acd91bb7038fb124a9eda39ab49d3db87aa844e15334eff740b23f77f","status":3,"epoch":110380149,"qty":900000000,"sell":false,"filled":900000000,"matches":[{"matchID":"b14243ed2bcf822a19105e4a66d4677f9aa8ef81c7c8a9b07be0e35ecea41d2b","status":1,"active":true,"revoked":false,"rate":881000000,"qty":200000000,"side":0,"feeRate":4046,"swap":{"id":"926539219f312558a086d90243913405ba0013ad04a5bbfd67ab858764a9d09e00000000","stringID":"9ed0a9648785ab67fdbba504ad1300ba0534914302d986a05825319f21396592:0","assetID":3,"symbol":"doge","confs":{"count":1,"required":2}},"stamp":1655702265000,"isCancel":false},{"matchID":"08da6e681e54168732accbf3ebc32dee16c74e06142bfb0e6924293710f1576a","status":0,"active":true,"revoked":false,"rate":881000000,"qty":200000000,"side":0,"feeRate":4046,"stamp":1655702280000,"isCancel":false},{"matchID":"4c53b4f5b2653a56ad0bc329475b02f68e40ed7812607f5c2f92442e9601474e","status":1,"active":true,"revoked":false,"rate":881000000,"qty":400000000,"side":0,"feeRate":4046,"swap":{"id":"926539219f312558a086d90243913405ba0013ad04a5bbfd67ab858764a9d09e00000001","stringID":"9ed0a9648785ab67fdbba504ad1300ba0534914302d986a05825319f21396592:1","assetID":3,"symbol":"doge","confs":{"count":1,"required":2}},"stamp":1655702265000,"isCancel":false},{"matchID":"24e8c512cec8bdb93e0f61ffed2b4e512eed30f8ba6b72cd1be702c3efa6ef5e","status":1,"active":true,"revoked":false,"rate":881000000,"qty":100000000,"side":0,"feeRate":4046,"swap":{"id":"926539219f312558a086d90243913405ba0013ad04a5bbfd67ab858764a9d09e00000002","stringID":"9ed0a9648785ab67fdbba504ad1300ba0534914302d986a05825319f21396592:2","assetID":3,"symbol":"doge","confs":{"count":1,"required":2}},"stamp":1655702265000,"isCancel":false}],"cancelling":false,"canceled":false,"feesPaid":{"swap":1165248,"redemption":0},"fundingCoins":[{"id":"1d51ff124d747bccdd714ba0c09cc1b3a3e483ca7ad75ccf96eb23bb1bfb7d1300000000","stringID":"137dfb1bbb23eb96cf5cd77aca83e4a3b3c19cc0a04b71ddcc7b744d12ff511d:0","assetID":3,"symbol":"doge"}],"lockedamt":9717035824885984,"accelerationCoins":[],"rate":881000000,"tif":1,"targetOrderID":""}}

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 20, 2022

And:

2022-06-20 14:38:46.186 [WRN] CORE:CMPD:STACKER:0: notify: |WARNING| (order) Match revoked - Match 8403231c has been revoked - Order: 2507294ed4672e0913db6ccfb50f492d432903bebe3f8b80f9ec56f2e8947214
2022-06-20 14:38:46.186 [WRN] CORE:CMPD:STACKER:0: Match 8403231ca1b8f5d2817238f04f69b3b4b307669b31f7214271ec09ecbbf362f7 revoked in status MakerSwapCast for order 2507294ed4672e0913db6ccfb50f492d432903bebe3f8b80f9ec56f2e8947214

...

2022-06-20 14:38:46.457 [ERR] CORE:CMPD:STACKER:1: notify: |ERROR| (order) Swap reporting error - Error notifying DEX of swap for match 8403231ca1b8f5d2817238f04f69b3b4b307669b31f7214271ec09ecbbf362f7: error sending 'init' message: rpc error: error code 6: unknown match ID - Order: e9fb8f53af6538de3721e08f25456449b243d705e81978cb0500bd08d8703ce4

Maybe need to set the client locktimes correctly for this one. They are using the default while server is the 30s/1m

Oh that's right, I should be building with the tags...

@JoeGruffins
Copy link
Member Author

Still seeing that last one even after building properly. Will make some issues I guess.

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 20, 2022

Find unused ports from @buck54321 : https://github.com/decred/dcrdex/compare/a68155e1aa3e76202b137dfa80604227016838cd..a2ad03d399015fc35e80a9ccc7fb66cc1de6292b

@chappjc
Copy link
Member

chappjc commented Jun 20, 2022

Regarding revoked matches in loadbot, while testing, I had wondered if it was even a good idea to use it with 30s/1m lock times rather than much higher. I need to check how the new block mining is triggered from loadbot, and if it's possible matches will occasionally just be revoked if not settled fast enough. (Given the recent proactive revoke changes to Swapper.)

@chappjc
Copy link
Member

chappjc commented Jun 20, 2022

No idea about the DOGE signing error (or is it spending a spent output?). Definitely make that an issue.

The order validation might just be a case of inadequate error detail - probably an order that was given a bad rate or quantity by loadbot.

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 20, 2022

The mining is rather random. I guess they overlap too.

I don't plan to change this pr any more unless there are requests to do so. Unless you have an idea for what the locktimes would be best, can change the comment.

So far no errors at all seen on the eth market! (knock on wood)

@chappjc
Copy link
Member

chappjc commented Jun 20, 2022

Nice! I've run this PR a bunch and have little trouble aside from compound draining a wallet of funds after 90 min or so.

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 20, 2022

Hmm, not sure how this can happen. Can doge overflow? :

2022-06-20 15:53:00.348 [ERR] CORE:CMPD:STACKER:0[doge]: Withdraw error - address = 'n3iHHzBXe7QQTVKjCa7274DZsXMuDmJWfo', amount = -7572350.60830305: SendToAddress error: rawrequest (sendtoaddress) error: -3: Amount out of range
2022-06-20 15:53:00.349 [ERR] CORE:CMPD:STACKER:0: notify: |ERROR| (withdraw) Withdraw error - Error encountered during doge withdraw: SendToAddress error: rawrequest (sendtoaddress) error: -3: Amount out of range
2022-06-20 15:53:00.349 [CRT] MANTLE:CMPD:STACKER:0: failed to withdraw funds to alpha: SendToAddress error: rawrequest (sendtoaddress) error: -3: Amount out of range

I should have had debugging on debug.

Oh 2022-06-20 17:01:45.211 [DBG] MANTLE:CMPD:SNIPER:0: Balance note received for doge (minFunds = 263.39999970, maxFunds = 526.79999940): {"available":18446028413044533643,"immature":375000967110148,"locked":11338976656907825,"stamp":"2022-06-20T17:01:45.209983109+09:00","orderlocked":0,"contractlocked":0}

What.

@chappjc chappjc merged commit 96fda47 into decred:master Jun 20, 2022
@chappjc
Copy link
Member

chappjc commented Jun 20, 2022

Can doge overflow

More likely underflow. Kinda wish we were using signed int64 for amounts more broadly.

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.

testing: core harness and loadbot tests need to be generalized
4 participants