feat(dex): cap LP providers with deterministic replacement#478
Conversation
d664734 to
62aa4d5
Compare
62aa4d5 to
6799d24
Compare
# Conflicts: # lib/mempool_test.go
rem1niscence
left a comment
There was a problem hiding this comment.
Please check the comments left
| } | ||
| } | ||
| // removes legacy zero-point “ghost” LPs | ||
| p.Points = slices.DeleteFunc(p.Points, func(point *lib.PoolPoints) bool { return point.Points == 0 }) |
There was a problem hiding this comment.
why do this deletion at the beginning of the function when it will be called again after the withdrawals are processed? shouldn't the second call also clean the "ghost" LPs?
There was a problem hiding this comment.
Yep, the second pass cleans old ghosts too if we actually reach it. The catch is the early return above: if the batch only touches zero-point holders, totalPointsToRemove is 0 and we never get to that second pass. So the first one clears old ghosts, and the second clears LPs this withdrawal just took to zero.
| func (s *Server) Transactions(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
| // create a slice to hold the incoming transactions | ||
| var txs []lib.TransactionI | ||
| var transactions []*lib.Transaction |
There was a problem hiding this comment.
what's the logic behind using the concrete type? when I first made this change I used the interface in order to avoid the iteration done now to cast to the concrete type as a small optimization, any reason to do this?
There was a problem hiding this comment.
Yeah, I wanted to keep the interface here too, but encoding/json can't instantiate entries in []lib.TransactionI, so normal tx objects fail to decode on the batch endpoint. Decoding into []*lib.Transaction gives it a concrete target. The loop is only wrapping pointers in the interface slice, not copying the txs, and keeps us from needing a custom decoder or a wider submitTxs change.
Summary
Validation
go list -e ./... | rg -v '/audit/' | xargs go testgo test -race ./fsm -run 'TestHandleBatch|Test.*Capped|Test.*Liquidity|TestHandleDexBatchOrdersEnforcesSettlementCap' -count=1go test -race ./lib -run 'TestCertificateResultsMayExceedIndividualMaxTxSize|TestDexBatch' -count=1The repository-wide
go test ./...also passes all normal packages; its only failures are checked-inaudit/**/artifactsrepro directories that are not standalone buildable packages.