Feature/169366221 flux monitor heartbeat#2233
Conversation
0a8a2ac to
57c7472
Compare
e41ce80 to
69a1ae6
Compare
There was a problem hiding this comment.
Any reason for this choice of default? Seems arbitrary.
There was a problem hiding this comment.
True, I've updated it to be greater than or equal to the pollingInterval
9f6bfb3 to
f340be9
Compare
| cancel context.CancelFunc | ||
| newRounds chan eth.Log | ||
|
|
||
| stopC chan struct{} |
There was a problem hiding this comment.
What's the significance of C in stopC? Is it indicating Checker or Channel?
There was a problem hiding this comment.
Its for channel, would you prefer another name or have any suggestions?
There was a problem hiding this comment.
I like the change to waitOnStop as we can lookup that it's channel from the type. Captures the intent well.
| {"inside deviation", decimal.NewFromInt(100), decimal.NewFromInt(101), 2, false}, | ||
| {"equal to deviation", decimal.NewFromInt(100), decimal.NewFromInt(102), 2, true}, | ||
| {"outside deviation", decimal.NewFromInt(100), decimal.NewFromInt(103), 2, true}, | ||
| {"outside deviation zero", decimal.NewFromInt(100), decimal.NewFromInt(0), 2, true}, |
There was a problem hiding this comment.
This is perhaps outside the scope of this PR...
But how do you feel about adding test coverage for when threshold is negative?
There was a problem hiding this comment.
The difference between current price and next price is computed as an absolute value... But if curPrice could go negative, OutsideDeviation would not trigger. I don't know whether there's a check elsewhere in the code that the price is non-negative. Decimals can be negative.
There was a problem hiding this comment.
i feel validation and these constraints are outside the scope for sure. It probably deserves its own story and we are waiting to hear back re: the audit.
coventry
left a comment
There was a problem hiding this comment.
Overall, this looks good, but there are some aspects to it I don't follow, and I think it would probably be helpful to other readers if you could clarify them in the code.
| func stopTimer(arg *time.Timer) { | ||
| if !arg.Stop() && len(arg.C) > 0 { | ||
| // timer's channel may have backlog | ||
| // refer to: https://developpaper.com/detailed-explanation-of-the-trap-of-timer-in-golang/ |
There was a problem hiding this comment.
Is there a more authoritative reference for this? The writing on that site is a bit difficult to follow.
The point is to drain the potential backlog? What could go wrong if you didn't?
There was a problem hiding this comment.
Authoritative yes, better explained, no. This was the best article I could find on the subject.
I've updated the comment, but I've assumed the reader has an understanding of the operation of the timer entity. Therefor I've left out what could go wrong.
| func (p *PollingDeviationChecker) Stop() { | ||
| if p.cancel != nil { | ||
| p.cancel() | ||
| <-p.stopC |
There was a problem hiding this comment.
I'm unsure about the purpose of this. Is it to hang until the channel is closed in the consumer loop?
I think an explanatory comment is helpful, when this kind of action at a distance is going on.
There was a problem hiding this comment.
I've renamed it to waitOnStop
| err = deviationChecker.Start(context.Background(), ethClient) | ||
| require.NoError(t, err) | ||
|
|
||
| <-fetchCalled // Called on start |
There was a problem hiding this comment.
This will hang on failure, which is a bit inconvenient. Would it be straightforward to wrap this in a timeout shorter than 10 minutes?
There was a problem hiding this comment.
Thanks for pointing this out
There was a problem hiding this comment.
I've improved the test a bit and fixed this problem in 8d49a90cc551dca77da8f13358ba71076a15482a
| {"inside deviation", decimal.NewFromInt(100), decimal.NewFromInt(101), 2, false}, | ||
| {"equal to deviation", decimal.NewFromInt(100), decimal.NewFromInt(102), 2, true}, | ||
| {"outside deviation", decimal.NewFromInt(100), decimal.NewFromInt(103), 2, true}, | ||
| {"outside deviation zero", decimal.NewFromInt(100), decimal.NewFromInt(0), 2, true}, |
There was a problem hiding this comment.
The difference between current price and next price is computed as an absolute value... But if curPrice could go negative, OutsideDeviation would not trigger. I don't know whether there's a check elsewhere in the code that the price is non-negative. Decimals can be negative.
8d49a90 to
34f4e1c
Compare
34f4e1c to
a8c55ae
Compare
|
It doesn't seem like this new |
a8c55ae to
9107e42
Compare
9f92b04 to
0057e68
Compare
There was a logic error where the idleThreshold was linked to the last time the price was polled, not updated. This is fixed in cdbdca3. Thanks for spotting this. |
660de6f to
804dd45
Compare
Allow chainlink operators to configure the Flux Monitor to trigger a Job Run if it has exceeded a specified 'idle time'. The 'idle time' is the time for which no Job Run has been started. The behavior is disabled if no IdleTime is defined. https://www.pivotaltracker.com/story/show/169366221 To make testing easier, ensure the DeviationChecker has stopped completely before returning.
Fix a logic error the implementation of the Idle Threshold by making the timeout occur since the last Job Run. The IdleThreshold is mistakenly linked to the last pollingInterval check.
804dd45 to
7709d56
Compare
Allow chainlink operators to configure the Flux Monitor to trigger a Job Run if it has exceeded a specified 'idle time'. The 'idle time' is the time for which no Job Run has been started.
The behavior is disabled if no idle time is defined.
https://www.pivotaltracker.com/story/show/169366221