-
Notifications
You must be signed in to change notification settings - Fork 94
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
Enhanced end condition #89
Conversation
Pull Request Test Coverage Report for Build 3236
💛 - Coveralls |
tipDelay int64, | ||
interval time.Duration, | ||
) { | ||
tc := time.NewTicker(interval) |
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 had no idea you could do this!! Very very cool!
internal/tester/data.go
Outdated
@@ -292,6 +298,31 @@ func (t *DataTester) StartPeriodicLogger( | |||
return ctx.Err() | |||
} | |||
|
|||
// WatchEndCondition starts go routines to watch the end conditions | |||
func (t *DataTester) WatchEndCondition( |
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.
nit: WatchEndConditions
configuration/configuration.go
Outdated
@@ -311,6 +311,13 @@ type DataConfiguration struct { | |||
// useful to just try to fetch all blocks before checking for balance | |||
// consistency. | |||
BalanceTrackingDisabled bool `json:"balance_tracking_disabled"` | |||
|
|||
// EndAtTip is an end condition. syncing will stop once tip is reached |
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 nest these in an EndConditions
object? I think we will have many end conditions?
} | ||
|
||
if atTip { | ||
log.Println("Node has reached tip") |
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.
nit: syncer has reached tip
atTip, err := s.blockStorage.AtTip(ctx, tipDelay) | ||
if err != nil { | ||
log.Printf( | ||
"%s: unable to evaluate if node is at tip", |
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.
nit: unable to evaluate if syncer is at tip
@@ -155,3 +157,60 @@ func (s *StatefulSyncer) BlockRemoved( | |||
|
|||
return err | |||
} | |||
|
|||
// EndAtTipLoop runs a loop that evaluates end condition EndAtTip | |||
func (s *StatefulSyncer) EndAtTipLoop( |
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.
@slowboat0 How do you feel about putting all end condition checks in a single go routine?
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.
When I initially thought about this PR, I thought about doing it that way. However, there is a cleanliness in using separate goroutines.
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'd like to keep it this way. One caveat of using single goroutine is that one expensive check on the condition (http timeout, db query timeout..) can block other condition checking as well.
I'm open to refactor once we've added more end conditions.
func (s *StatefulSyncer) EndAtTipLoop( | ||
ctx context.Context, | ||
tipDelay int64, | ||
interval time.Duration, |
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 do we have this as an arg? This seems like it should be a const somewhere?
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 is a constant used by caller https://github.com/coinbase/rosetta-cli/blob/luke/enhance-end-condition/internal/tester/data.go#L58-L62
59ffb55
to
d1761c3
Compare
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.
We may need to rethink this a little to handle Construction API end conditions well, but this is a great start! 🎉
Closes: #66
Add end condition
end_at_tip
andend_duration
for thecheck:data
command.User can specify the end conditions under the
data/end_conditions
section of the configuration file.For example, to exit when
tip is reached
ORafter 3600 secs
:Changes
end_at_tip
implementationend_duration
implementation