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: return error instead of panic for behaviors triggered by client #1395

Merged
merged 13 commits into from
May 24, 2024

Conversation

tkxkd0159
Copy link
Member

@tkxkd0159 tkxkd0159 commented May 23, 2024

Description

closes: #XXXX

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@tkxkd0159 tkxkd0159 added the A: improvement Changes in existing functionality label May 23, 2024
@tkxkd0159 tkxkd0159 self-assigned this May 23, 2024
@tkxkd0159 tkxkd0159 changed the title chore: return error instead of panic for action triggered by client during bridge transfer chore: return error instead of panic for insufficient balance during bridge transfer May 23, 2024
@tkxkd0159 tkxkd0159 changed the title chore: return error instead of panic for insufficient balance during bridge transfer fix: return error instead of panic for insufficient balance during bridge transfer May 23, 2024
Copy link

codecov bot commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.69%. Comparing base (6ca08db) to head (551b78b).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1395   +/-   ##
=======================================
  Coverage   69.68%   69.69%           
=======================================
  Files         668      668           
  Lines       56242    56242           
=======================================
+ Hits        39194    39198    +4     
+ Misses      14775    14773    -2     
+ Partials     2273     2271    -2     
Files Coverage Δ
x/fbridge/keeper/transfer.go 81.81% <100.00%> (+7.27%) ⬆️

Copy link
Collaborator

@0Tech 0Tech left a comment

Choose a reason for hiding this comment

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

It could be nice to address other panics on x/fbridge. I found 2 points:

  • critical
    • keeper/abci.go#L36: In theory, updateRole() can return error by registering two identical role suggestions. So we have to update the error handling or the chain halts.
  • good-to-have
    • keeper/genesis.go#L22 and L28: setRole() and setBridgeSwitch() may return error because of its argument verification. It that case, InitGenesis() panics, instead of returning errors. However, if InitGenesis() returns any errors, eventually it will panic by the module. Hence, it would be good to return errors or modify the signature of InitGenesis() so it won't return any errors.

@tkxkd0159 tkxkd0159 changed the title fix: return error instead of panic for insufficient balance during bridge transfer fix: return error instead of panic for behaviors triggered by client May 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 24, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 70.02%. Comparing base (6ca08db) to head (402f0f3).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1395      +/-   ##
==========================================
+ Coverage   69.68%   70.02%   +0.33%     
==========================================
  Files         668      672       +4     
  Lines       56242    56866     +624     
==========================================
+ Hits        39194    39818     +624     
  Misses      14775    14775              
  Partials     2273     2273              
Files Coverage Δ
x/fbridge/keeper/transfer.go 81.81% <100.00%> (+7.27%) ⬆️
x/fbridge/keeper/genesis.go 8.47% <0.00%> (ø)
x/fbridge/keeper/auth.go 57.84% <25.00%> (+0.70%) ⬆️
x/fbridge/keeper/abci.go 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

Copy link
Collaborator

@0Tech 0Tech left a comment

Choose a reason for hiding this comment

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

And please mind keeper/genesis.go#L22.

x/fbridge/keeper/auth_test.go Show resolved Hide resolved
x/fbridge/keeper/auth.go Show resolved Hide resolved
0Tech
0Tech previously approved these changes May 24, 2024
x/fbridge/keeper/abci.go Outdated Show resolved Hide resolved
@tkxkd0159 tkxkd0159 merged commit 6c90f1e into main May 24, 2024
37 of 38 checks passed
@tkxkd0159 tkxkd0159 deleted the handle-bridge-err branch May 24, 2024 06:33
mergify bot pushed a commit that referenced this pull request May 24, 2024
zemyblue pushed a commit that referenced this pull request May 24, 2024
…1395) (#1400)

(cherry picked from commit 6c90f1e)

Co-authored-by: Jeseung Lee <41176085+tkxkd0159@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: improvement Changes in existing functionality backport/v0.49.x C:x/fbridge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants