-
Notifications
You must be signed in to change notification settings - Fork 54
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
Avoid panics #389
base: dev
Are you sure you want to change the base?
Avoid panics #389
Conversation
metrics := NewMetrics(reg, "example", logger) | ||
return client, NewGeometricTxnManager(client, wallet, logger, metrics, GeometricTxnManagerParams{}), nil | ||
} | ||
|
||
func ExampleGeometricTxManager() { | ||
anvilC, err := testutils.StartAnvilContainer("") | ||
if err != 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.
I think we should also avoid the use of panics in the examples as well
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.
Done
@@ -76,11 +76,16 @@ func (ar *AvsRegistryServiceChainCaller) GetOperatorsAvsStateAtBlock( | |||
} | |||
numquorums := len(quorumNumbers) | |||
if len(operatorsStakesInQuorums) != numquorums { | |||
ar.logger.Fatal( | |||
ar.logger.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.
I would add the values of operatorsStakesInQuorums
and numquorums
in this log for debugging
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.
Done
@@ -128,8 +123,9 @@ func (ops *OperatorsInfoServiceInMemory) startServiceInGoroutine( | |||
queryC <-chan query, | |||
wg *sync.WaitGroup, | |||
opts Opts, | |||
) { | |||
go func() { | |||
) chan<- 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.
I think it would be more readable/and simplify error handling if we replaced the error channel with an error group 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.
Great idea! I added it.
Fixes # .
What Changed?
The functions
BuildReadClients
,BuildAll
,NewZapLoggerByConfig
, andAvsRegistryServiceChainCaller.GetOperatorsAvsStateAtBlock
return errors instead of panicking.The
OperatorsInfoServiceInMemory
no longer panics (errors are only logged).Reviewer Checklist