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

chore(state-transition): improving applyDeposit error handling #2062

Open
wants to merge 14 commits into
base: storage-cleanup-err-not-found
Choose a base branch
from

Conversation

abi87
Copy link
Contributor

@abi87 abi87 commented Oct 10, 2024

stateProcessor.applyDeposit assumed that the only possible error when querying for a validator was that the validator did not exist, in which case it creates it.
This is brittle. This PR handles errors differently. A validator is created only if ErrNotFound is returned, otherwise applyDeposit returns the error to the client and does not go ahead creating a new validator.

@abi87 abi87 self-assigned this Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 22.07%. Comparing base (3e88d11) to head (3bcc022).

Files with missing lines Patch % Lines
...ad/pkg/state-transition/state_processor_staking.go 0.00% 12 Missing ⚠️
...ate-transition/pkg/core/state_processor_staking.go 0.00% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                        Coverage Diff                        @@
##           storage-cleanup-err-not-found    #2062      +/-   ##
=================================================================
- Coverage                          22.09%   22.07%   -0.02%     
=================================================================
  Files                                357      357              
  Lines                              16192    16205      +13     
  Branches                              12       12              
=================================================================
  Hits                                3578     3578              
- Misses                             12463    12476      +13     
  Partials                             151      151              
Files with missing lines Coverage Δ
...ate-transition/pkg/core/state_processor_staking.go 0.00% <0.00%> (ø)
...ad/pkg/state-transition/state_processor_staking.go 0.00% <0.00%> (ø)

@@ -1,3 +1,11 @@
cosmossdk.io/api v0.7.0 h1:QsEMIWuv9xWDbF2HZnW4Lpu1/SejCztPu0LQx7t6MN4=
cosmossdk.io/api v0.7.0/go.mod h1:kJFAEMLN57y0viszHDPLMmieF0471o5QAwwApa+270M=
Copy link
Member

Choose a reason for hiding this comment

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

introducing cosmos deps to state-transition is bad

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I believe we have to properly handle the errors from state, however unlikely they are. Will work on finding a different way for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebasing this PR on top of a couple of others, I managed to ditch the direct cosmos sdk dependency and have state-transition depend on storage instead

@abi87 abi87 changed the base branch from main to storage-no-err-silencing October 15, 2024 16:12
Base automatically changed from storage-no-err-silencing to storage-cleanup-err-not-found October 15, 2024 21:32
@abi87 abi87 marked this pull request as ready for review October 16, 2024 07:37
@abi87 abi87 requested a review from itsdevbear October 16, 2024 07:39
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.

2 participants