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

PRT-88: Prevent potential panic in the tendermintRPC #139

Merged
merged 6 commits into from
Nov 17, 2022

Conversation

0xAleksaOpacic
Copy link
Contributor

Description

Inside tendermintRPC.go we have potential panic. If these methods:

  1. https://github.com/lavanet/lava/blob/main/relayer/chainproxy/tendermintRPC.go#L340
  2. https://github.com/lavanet/lava/blob/main/relayer/chainproxy/tendermintRPC.go#L345

returns an error, rpcMessage object will be nil, which means that convertMsg method would not be able to extract fields and it will panic

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • New feature (non-breaking change that adds functionality)

@kajeagentspi
Copy link
Contributor

Nice catch!

Copy link
Contributor

@SeanZoR SeanZoR left a comment

Choose a reason for hiding this comment

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

Very good PR title and descirption in the body, thanks!
Can you add the Jira ticket please?

@0xAleksaOpacic
Copy link
Contributor Author

Inside tendermintRPC.go we have potential panic. If these methods:

  1. https://github.com/lavanet/lava/blob/main/relayer/chainproxy/tendermintRPC.go#L340
  2. https://github.com/lavanet/lava/blob/main/relayer/chainproxy/tendermintRPC.go#L345

returns an error, rpcMessage object will be nil, which means that convertMsg method would not be able to extract fields and it will panic

Thanks, I opened it (PRT-88)! Next time I will use branch_naming from Jira (i can not change it now )

@0xAleksaOpacic 0xAleksaOpacic changed the title Prevent potential panic in the tendermintRPC PRT-88 Prevent potential panic in the tendermintRPC Nov 17, 2022
@0xAleksaOpacic 0xAleksaOpacic changed the title PRT-88 Prevent potential panic in the tendermintRPC PRT-88: Prevent potential panic in the tendermintRPC Nov 17, 2022
relayer/chainproxy/tendermintRPC.go Outdated Show resolved Hide resolved
@0xAleksaOpacic 0xAleksaOpacic force-pushed the fix/prevent_potential_panic branch from 3610625 to 0fdb6b8 Compare November 17, 2022 12:17
relayer/chainproxy/chainproxy.go Outdated Show resolved Hide resolved
relayer/chainproxy/jsonRPC.go Outdated Show resolved Hide resolved
relayer/chainproxy/tendermintRPC.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ranlavanet ranlavanet left a comment

Choose a reason for hiding this comment

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

last change :)

)

var (
errFailedToConvertMessage = sdkerrors.New("RPC error", 1000, "failed to convert a message")
Copy link
Collaborator

Choose a reason for hiding this comment

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

usually errors would be with a capital letter so they will be available for other packages as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries, we need to make our code as code as possible :D

I usually make them exportable only if they are used outside, but cool will follow structure we have 9d86272

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the build error 9b3d0d6

@ranlavanet ranlavanet merged commit a8cd010 into main Nov 17, 2022
@0xAleksaOpacic 0xAleksaOpacic deleted the fix/prevent_potential_panic branch November 17, 2022 14:29
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.

4 participants