-
Notifications
You must be signed in to change notification settings - Fork 41
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
BEP67 Price-based Order Expiration #704
Conversation
@@ -433,3 +433,51 @@ func (ull *ULList) UpdateForEach(updater LevelIter) { | |||
b = oldNext | |||
} | |||
} | |||
|
|||
func (ull *ULList) UpdateForEachBiasedly(preferenceSize int, preferenceUpdater LevelIter, updater LevelIter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reuse the original UpdateForEach
, I think we can change the updater
function itself.
6dec50f
to
f68f997
Compare
plugins/dex/matcheng/types.go
Outdated
@@ -190,7 +190,7 @@ func (overlapped *OverLappedLevel) HasSellTaker() bool { | |||
return overlapped.SellTakerStartIdx < len(overlapped.SellOrders) | |||
} | |||
|
|||
type LevelIter func(*PriceLevel) | |||
type LevelIter func(priceLevel *PriceLevel, currentLevel int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest renaming the currentLevel
to levelIndex
plugins/dex/matcheng/orderbook.go
Outdated
return nil | ||
} | ||
|
||
func (ob *OrderBookOnULList) UpdateForEachPriceLevel(side int8, updater func(priceLevel *PriceLevel, currentLevel int)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use LevelIter
as the updater's type
plugins/dex/order/keeper.go
Outdated
@@ -831,6 +832,17 @@ func (kp *Keeper) expireOrders(ctx sdk.Context, blockTime time.Time) []chan Tran | |||
return nil | |||
} | |||
|
|||
var forceExpireHeight int64 | |||
var err2 error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err2 is not a good name, actually you can just reuse the err
plugins/dex/order/keeper.go
Outdated
numPricesStored = 2000 | ||
pricesStoreEvery = 1000 | ||
minimalNumPrices = 500 | ||
bep2PreferencePriceLevel = 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add a bep2 prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mini-token may have less price levels for orders living longer than 3 days
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove bep2 prefix first. You can change that when you really need it in mini token PR
plugins/dex/matcheng/orderbook.go
Outdated
@@ -20,7 +20,8 @@ type OrderBookInterface interface { | |||
GetOrder(id string, side int8, price int64) (OrderPart, error) | |||
RemoveOrder(id string, side int8, price int64) (OrderPart, error) | |||
RemoveOrders(beforeTime int64, side int8, cb func(OrderPart)) error | |||
UpdateForEachPriceLevel(side int8, updater func(*PriceLevel)) | |||
RemoveOrdersBiasedly(beforeTime int64, forceTime int64, preferenceSize int, side int8, removeCallback func(ord OrderPart)) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method name is confusing, so are the parameter names.
common/upgrade/upgrade.go
Outdated
@@ -8,6 +8,7 @@ var Mgr = sdk.UpgradeMgr | |||
// bugfix: fix | |||
// improvement: (maybe bep ?) | |||
const ( | |||
BEPX = "BEPX" //placeholder for expire order extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we do not have a corresponding BEP, just give it a meaningful name.
Also, you need to register the upgrade with an upgrade height
3f809f0
to
acd72cb
Compare
app/app.go
Outdated
@@ -253,6 +253,7 @@ func NewBinanceChain(logger log.Logger, db dbm.DB, traceStore io.Writer, baseApp | |||
// setUpgradeConfig will overwrite default upgrade config | |||
func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) { | |||
// register upgrade height | |||
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP67, upgradeConfig.BEP6Height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put the upgrade config in the right order.
app/config/config.go
Outdated
@@ -47,6 +47,8 @@ orderKeeperConcurrency = {{ .BaseConfig.OrderKeeperConcurrency }} | |||
breatheBlockDaysCountBack = {{ .BaseConfig.BreatheBlockDaysCountBack }} | |||
|
|||
[upgrade] | |||
# Block height of BEP67 upgrade | |||
BEP67Height = {{ .UpgradeConfig.BEP67Height }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
plugins/dex/order/keeper.go
Outdated
const forceExpireDays = 30 | ||
forceExpireHeight, err = kp.GetBreatheBlockHeight(ctx, blockTime, forceExpireDays) | ||
if err != nil { | ||
kp.logger.Info(err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use kp.logger.Error. Also for the #831
plugins/dex/order/keeper.go
Outdated
kp.logger.Info(err.Error()) | ||
forceExpireHeight = -1 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to extract a method get the expireHeight and forceExpireHeight.
e.g. func getExpireHeight(...) (expireHeight, forceExpireHeight int64)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForceExpireHeight is only needed after BEP67
@@ -395,6 +395,7 @@ func (ull *ULList) GetPriceLevel(p int64) *PriceLevel { | |||
func (ull *ULList) UpdateForEach(updater LevelIter) { | |||
b := ull.begin | |||
var last *bucket | |||
iteratedCount := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
levelIndex may be better
@@ -190,7 +190,7 @@ func (overlapped *OverLappedLevel) HasSellTaker() bool { | |||
return overlapped.SellTakerStartIdx < len(overlapped.SellOrders) | |||
} | |||
|
|||
type LevelIter func(*PriceLevel) | |||
type LevelIter func(priceLevel *PriceLevel, levelIndex int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type of levelIndex should be int64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max level Index is int
func (ob *OrderBookOnULList) ShowDepth(maxLevels int, iterBuy LevelIter, iterSell LevelIter) {
ob.buyQueue.Iterate(maxLevels, iterBuy)
ob.sellQueue.Iterate(maxLevels, iterSell)
}
2435876
to
8f86d0e
Compare
fix & test format extract preference size as param format: refactor updator fix format rename arg refactor
8f86d0e
to
81875bd
Compare
Description
expiration time unchanged (3 days), but keep orders in the best 500 price levels on both ask and bid for at most 1 month.
Rationale
tell us why we need these changes...
Some users want to keep their open orders more than 3 days.
add a way user can extend the order life to stay longer than 72 hours
add an example CLI or API response...
Changes
Notable changes:
Preflight checks
make build
)make test
)make integration_test
)Already reviewed by
...
Related issues
... reference related issue #'s here ...