-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
LGTM alerts audit #7440
LGTM alerts audit #7440
Conversation
@@ -614,7 +614,7 @@ func (k Keeper) Delegate( | |||
} | |||
} | |||
|
|||
validator, newShares = k.AddValidatorTokensAndShares(ctx, validator, bondAmt) |
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 wonder why the validator value is not set to store?
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.
cc: @cwgoes @alexanderbez
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.
AddValidatorTokensAndShares
stores the validator already via a call to k.SetValidator
. This line can be _, newShares = k.AddValidatorTokensAndShares(ctx, validator, bondAmt)
.
Codecov Report
@@ Coverage Diff @@
## master #7440 +/- ##
==========================================
- Coverage 55.10% 55.09% -0.01%
==========================================
Files 588 588
Lines 36787 36782 -5
==========================================
- Hits 20270 20266 -4
+ Misses 14416 14415 -1
Partials 2101 2101 |
This pull request fixes 5 alerts when merging 45f11ae into 2c93ec7 - view on LGTM.com fixed alerts:
|
if err != nil { | ||
return 0, err | ||
} | ||
|
||
if i < 0 { | ||
return 0, fmt.Errorf("fields must not be negative. got %d", i) |
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.
The string "fields must not be negative. got %d"
is very informative. What will it be replaced with?
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 don't need it as the string is already cast to uint
@fedekunze dixit:
Which line is it? I can't find the alert |
Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: Alessio Treglia <[email protected]>
This pull request fixes 5 alerts when merging 10c3e33 into 2c93ec7 - view on LGTM.com fixed alerts:
|
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.
haha OK
// validator already exists | ||
mVal.val = update |
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.
Why did this code get removed?
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.
not used apparently
Thank you @fedekunze for this change! However, I think LGTM gave you a false positive and I'd roll back this change. It is most definitely depending on just single static assignment analyses of sorts, (so basically shaving off unnecessary operations) but really the parameters to deriveKey take in but even more subtle is that we were expecting always an int32, and if harden is set, we explicitly set the 1<<32 bit on as per the spec in cosmos-sdk/crypto/hd/hdpath.go Lines 209 to 216 in 2c93ec7
We shall definitely need a test for extended keys without harden set and ensure that we don't accept values greater than (1<<31-1) Perhaps let me file an issue too. |
Lol @LGTM.io, what happens if someone imports and then uses that code? It’s
going to cause a bunch of undefined behaviour. For sets like that I’d
personally ignore because the inverse won’t be caught by that service.
…On Thu, Oct 22, 2020 at 6:02 AM Federico Kunze ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In x/simulation/mock_tendermint.go
<#7440 (comment)>:
> // validator already exists
- mVal.val = update
not used apparently
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7440 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3V5EZWBS3TZE33F2ZYTSMAUPZANCNFSM4SBQF6BA>
.
|
Fixes issues reported by LGTM.com.