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

mm: bot panics (trying to placeMultiTrade) #3130

Open
norwnd opened this issue Dec 24, 2024 · 1 comment
Open

mm: bot panics (trying to placeMultiTrade) #3130

norwnd opened this issue Dec 24, 2024 · 1 comment

Comments

@norwnd
Copy link
Contributor

norwnd commented Dec 24, 2024

MM bot panic (note, I'm running my own fork at https://github.com/norwnd/dcrdex/commits/master - but this is probably relevant for thus upstream repo too):

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x102a4c268]

goroutine 4980 [running]:
decred.org/dcrdex/client/mm.(*unifiedExchangeAdaptor).placeMultiTrade(0x14006ba6600, {0x1400b60a0a0, 0x1, 0x10383541c?}, 0x1)
	/Users/norwnd/dcrdex/client/mm/exchange_adaptor.go:970 +0x438
decred.org/dcrdex/client/mm.(*unifiedExchangeAdaptor).multiTrade(0x14006ba6600, {0x1400b60a088, 0x1, 0x1400b608150?}, 0x1, 0x0, 0x6e4f8d3)
	/Users/norwnd/dcrdex/client/mm/exchange_adaptor.go:1343 +0xc60
decred.org/dcrdex/client/mm.(*basicMarketMaker).rebalance(0x140087e20c0, 0x6e4f8d3)
	/Users/norwnd/dcrdex/client/mm/mm_basic.go:590 +0x274
decred.org/dcrdex/client/mm.(*basicMarketMaker).botLoop.func1()
	/Users/norwnd/dcrdex/client/mm/mm_basic.go:634 +0x294
created by decred.org/dcrdex/client/mm.(*basicMarketMaker).botLoop in goroutine 3828
	/Users/norwnd/dcrdex/client/mm/mm_basic.go:619 +0x26c
make: *** [a] Error 2

I think MultiTrade func needs to be adjusted like this:

// MultiTrade is used to place multiple standing limit orders on the same
// side of the same market simultaneously.
func (c *Core) MultiTrade(pw []byte, form *MultiTradeForm) []*MultiTradeResult {
	results := make([]*MultiTradeResult, 0, len(form.Placements))
	reqs, err := c.prepareMultiTradeRequests(pw, form)
	if err != nil {
		for range form.Placements {
			results = append(results, &MultiTradeResult{Error: err})
		}
		return results
	}

	for _, req := range reqs {
		var corder *Order
		corder, err = c.sendTradeRequest(req)
		if err != nil {
			results = append(results, &MultiTradeResult{Error: err})
			continue
		}
		results = append(results, &MultiTradeResult{Order: corder})
	}

	return results
}

there is a related "sanity-check" in MM code after MultiTrade is called (but it's always gonna pass with master code version):

	if len(placements) != len(results) {
		u.log.Errorf("unexpected number of results. expected %d, got %d", len(placements), len(results))
		return results
	}

not sure if all that ^ means there is a deeper underlying issue, but panic is certainly not a desired outcome.

norwnd pushed a commit to norwnd/dcrdex that referenced this issue Dec 24, 2024
@ancow
Copy link

ancow commented Dec 31, 2024

I'm getting what seems like the same error on a vanilla decred v2.0.5 install:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xaae6ed]

goroutine 11569 [running]:
decred.org/dcrdex/client/mm.(*unifiedExchangeAdaptor).placeMultiTrade(0xc00270b000, {0xc01f18aae0, 0x3, 0xc000dd9860?}, 0x1)
        decred.org/dcrdex@v1.0.2/client/mm/exchange_adaptor.go:970 +0x52d
decred.org/dcrdex/client/mm.(*unifiedExchangeAdaptor).multiTrade(0xc00270b000, {0xc00ed492d8, 0x3, 0xc001012bc0?}, 0x1, 0x3f60624dd2f1a9fc, 0x6e59a8d)
        decred.org/dcrdex@v1.0.2/client/mm/exchange_adaptor.go:1342 +0x104c
decred.org/dcrdex/client/mm.(*basicMarketMaker).rebalance(0xc000c1df88?, 0x6e59a8d)
        decred.org/dcrdex@v1.0.2/client/mm/mm_basic.go:392 +0x26d
decred.org/dcrdex/client/mm.(*basicMarketMaker).botLoop.func1()
        decred.org/dcrdex@v1.0.2/client/mm/mm_basic.go:429 +0x185
created by decred.org/dcrdex/client/mm.(*basicMarketMaker).botLoop in goroutine 11466
        decred.org/dcrdex@v1.0.2/client/mm/mm_basic.go:421 +0x275

My DCRDEX score keeps suffering because of this...

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

No branches or pull requests

2 participants