-
Notifications
You must be signed in to change notification settings - Fork 113
core, orderwatch, meshdb: Implement a dynamically decreasing max expiration time for orders #450
Conversation
48fcd11
to
f5896bb
Compare
11e0fa4
to
cdece2c
Compare
a11d5aa
to
6eb6010
Compare
511dc61
to
3c32584
Compare
6d02665
to
b7d3fa6
Compare
@fabioberger Removed WIP tag. This PR is ready for final review. I do eventually want to optimize our |
Update: I added this. |
963aa94
to
4eded3b
Compare
Co-Authored-By: Fabio B <me@fabioberger.com>
Co-Authored-By: Fabio B <me@fabioberger.com>
ddae068
to
a5bfe82
Compare
// Final expiration time check before inserting the order. We might have just | ||
// changed max expiration time above. | ||
if orderInfo.SignedOrder.ExpirationTimeSeconds.Cmp(w.maxExpirationTime) == 1 { | ||
return nil |
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.
Won't this mean that the node operator won't get the STOPPED_WATCHING
event emitted?
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.
@fabioberger Yes but it also means they never received the ADDED
event, which seems consistent to me. What do you think is the right behavior here?
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 ACK
d the incoming JSON-RPC request, we should return STOPPED_WATCHING
.
Co-Authored-By: Fabio B <me@fabioberger.com>
Co-Authored-By: Fabio B <me@fabioberger.com>
Co-Authored-By: Fabio B <me@fabioberger.com>
…/0x-mesh into feature/dynamic-max-expiration
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.
Small typo but otherwise LGTM!
Co-Authored-By: Fabio B <me@fabioberger.com>
Fixes #431.
This PR is still a WIP but I'm opening it now so we can discuss the progress so far. This is an implementation of the idea we've been discussing on Slack and a solution to the problem of finite database storage. To quickly re-summarize the idea:
When storage space is plentiful, we start without any kind of limit on expiration time. As the database fills up, we enforce a limit on the maximum expiration time. Any orders that expire after that time will be removed. If more orders keep coming in we can lower the expiration time and remove more orders.
So far this PR adds an index on
ExpirationTime
and implements a new method calledTrimOrdersByExpirationTime
which contains the bulk of the core logic for this feature. There are still some challenges around how to use this function and when to call it, but the approach is looking very feasible as of now. We also still need to determine when and how quickly to increase the max expiration time after storage frees up.