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 · 0 comments
Open

mm: bot panics (trying to placeMultiTrade) #3130

norwnd opened this issue Dec 24, 2024 · 0 comments

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
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

1 participant