Skip to content
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

fix: add checks on ResultBroadcastTx to avoid NPE + cleanup error handling code #18

Merged
merged 5 commits into from
Nov 21, 2023

Conversation

jtieri
Copy link
Contributor

@jtieri jtieri commented Nov 13, 2023

This PR adds an additional check on ResultBroadcastTx, which is returned by BroadcastTxSync, to ensure the result is not nil before attempting to log the response code and logs.

This also cleans up the error handling code to remove duplicate code and separates concerns into smaller functions for better readability and maintainability.

Closes #17

@jtieri jtieri marked this pull request as ready for review November 13, 2023 22:57
@jtieri jtieri requested review from agouin and bd21 November 13, 2023 22:59
// Log the error
logger.Error(fmt.Sprintf("error during broadcast: %s", getErrorString(err, rpcResponse)))

if err != nil || rpcResponse == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is nested in the previous "if" statement, is this if err != ni necessary?

@@ -66,7 +67,7 @@ func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *t
for _, historicalLog := range history {
parsedMsg, err := types.EvmLogToMessageState(messageTransmitterABI, messageSent, &historicalLog)
if err != nil {
logger.Error("Unable to parse history log into MessageState, skipping")
logger.Error("Unable to parse history log into MessageState, skipping", "err", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I had the same idea in order to help with issues like #9.
I think this PR could close out that issue too.

@boojamya
Copy link
Member

Also, we should merge into testnet branch first before merging to main.

Copy link
Contributor

@bd21 bd21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bd21 bd21 merged commit 8c2d916 into main Nov 21, 2023
1 check passed
@bd21 bd21 deleted the justin/fix-invalid-char branch November 21, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] nil pointer exception thrown in Broadcast when BroadcastTxSync returns nil ResultBroadcastTx
3 participants