Skip to content

Conversation

@cce
Copy link
Contributor

@cce cce commented Jul 16, 2021

Summary

The ineffassign linter is in the default set of linters enabled by golangci-lint but wasn't added in #2523 because it was reporting issues.

It's also one of the least objectionable linters; ineffectual assignments are rarely intentional and can point out bugs related to assumptions that a variable assignment had some effect.

There were various fixes here but I'm not sure if all the changes to remove or fix ineffectual assignments were the right ones.

Test Plan

Existing tests should ideally pass.

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2021

Codecov Report

Merging #2574 (b338f54) into master (b1ab372) will increase coverage by 0.05%.
The diff coverage is 15.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2574      +/-   ##
==========================================
+ Coverage   46.90%   46.95%   +0.05%     
==========================================
  Files         346      348       +2     
  Lines       55697    55716      +19     
==========================================
+ Hits        26125    26164      +39     
+ Misses      26615    26607       -8     
+ Partials     2957     2945      -12     
Impacted Files Coverage Δ
catchup/service.go 68.83% <0.00%> (-0.18%) ⬇️
cmd/goal/account.go 14.78% <ø> (+0.04%) ⬆️
cmd/tealdbg/localLedger.go 58.57% <0.00%> (-1.73%) ⬇️
ledger/acctupdates.go 62.30% <ø> (+0.38%) ⬆️
logging/log.go 41.46% <0.00%> (-1.40%) ⬇️
logging/telemetry.go 80.86% <ø> (-0.17%) ⬇️
rpcs/blockService.go 53.53% <ø> (+0.53%) ⬆️
rpcs/ledgerService.go 0.00% <ø> (ø)
agreement/proposal.go 71.96% <100.00%> (ø)
cmd/tealdbg/cdtState.go 83.69% <100.00%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1ab372...b338f54. Read the comment docs.

if cfg.MinFee > fee {
fee = cfg.MinFee
}
var fee uint64
Copy link
Contributor

Choose a reason for hiding this comment

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

while this code is technically correct, I think that we shouldn't do that as is.
Instead, we need to evaluate the bigger picture and (Maybe) eliminate the MinFee from the config file, as it seems redundant.

Copy link
Contributor Author

@cce cce Jul 16, 2021

Choose a reason for hiding this comment

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

Yes I left a comment here https://github.com/algorand/go-algorand/pull/1715/files#r671536585 about whether this was intentional or not ... I wasn't sure if this uncovered a bug or need to fix/clarify something like you're saying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pinging @algorandskiy for his opinion since these lines here were made ineffectual by #1715

Copy link
Contributor

Choose a reason for hiding this comment

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

MinFee is used in fee() func only for fee randomization. I think it is OK to remove it completely as a separate PR. For this one removing the branch is perfectly fine.

A note about using SuggestedFee here: pingpong funds accounts between iterations to ensure they have enough algos to interact, and on a high load with app/assets they some of them might not have enough algos to submit new transactions because the pool conjunction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh OK, I see so MinFee is still used in pingpong.go:WorkerState.fee(). I just wanted to make sure you realized these lines 156-159 being removed above were ineffectual (1000 is unused, and fee = cfg.MinFee is always overwritten).

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

several small requests, but looks great otherwise!

if s.cfg.CatchupVerifyTransactionSignatures() || s.cfg.CatchupVerifyApplyData() {
vb, err := s.ledger.Validate(s.ctx, *block, s.blockValidationPool)
var vb *ledger.ValidatedBlock
vb, err = s.ledger.Validate(s.ctx, *block, s.blockValidationPool)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsachiherman this is the most significant issue I found — before this change, the value of err = s.ledger.AddValidatedBlock(*vb, *cert) on line 319/320 is ineffectual, and has no impact later on line 324/325 where it checks if err != nil

@tsachiherman tsachiherman dismissed their stale review July 20, 2021 23:17

request changes applied. I'm going to wait for @algorandskiy feedback before approving & merging this one in.

if cfg.MinFee > fee {
fee = cfg.MinFee
}
var fee uint64
Copy link
Contributor

Choose a reason for hiding this comment

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

MinFee is used in fee() func only for fee randomization. I think it is OK to remove it completely as a separate PR. For this one removing the branch is perfectly fine.

A note about using SuggestedFee here: pingpong funds accounts between iterations to ensure they have enough algos to interact, and on a high load with app/assets they some of them might not have enough algos to submit new transactions because the pool conjunction.

@tsachiherman tsachiherman merged commit 07d3c1a into algorand:master Jul 22, 2021
@cce cce deleted the linter-ineffassign-clean branch July 28, 2021 01:25
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