-
Notifications
You must be signed in to change notification settings - Fork 137
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
[storage] Protect against nil Helper and/or Handler in BalanceStorage #273
Conversation
Pull Request Test Coverage Report for Build 13586
💛 - Coveralls |
@@ -187,6 +187,10 @@ func (b *BalanceStorage) AddingBlock( | |||
block *types.Block, | |||
transaction database.Transaction, | |||
) (database.CommitWorker, error) { | |||
if b.handler == 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.
Can we force the handler to be present in the methods used to create a new BalanceStorage instance?
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 wish! There is a somewhat complex dependency process where we can't add the handler or helper during initialization.
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 need a reference to BalanceStorage
to create some useful helpers (we should probably clean this up after this release but it will be a pretty big refactor 😢 ): https://github.com/coinbase/rosetta-cli/blob/972a1690001f7f7d22fafa0a580512eac8517add/pkg/tester/data.go#L284-L305
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.
yeah, we should def clean it up!
@@ -187,6 +187,10 @@ func (b *BalanceStorage) AddingBlock( | |||
block *types.Block, | |||
transaction database.Transaction, | |||
) (database.CommitWorker, error) { | |||
if b.handler == 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.
yeah, we should def clean it up!
Someone was able to force a panic in
rosetta-cli
because of an unpopulated BalanceStorage helper and handler. This PR causes BalanceStorage to raise an error in these cases instead of panicking.Changes