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

lint: enable govet shadow linter and resolve linter warnings #5261

Merged
merged 10 commits into from
Jun 1, 2023
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into govet-shadow-linter
  • Loading branch information
cce committed May 17, 2023
commit a013d8a769488966616f03286ce6397967173191
2 changes: 1 addition & 1 deletion cmd/algocfg/profileCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var setProfileCmd = &cobra.Command{
}
file := filepath.Join(dataDir, config.ConfigFilename)
if _, statErr := os.Stat(file); !forceUpdate && statErr == nil {
fmt.Printf("A config.json file already exists for this data directory. Would you like to overwrite it? (Y/n)")
fmt.Printf("A config.json file already exists at %s\nWould you like to overwrite it? (Y/n)", file)
reader := bufio.NewReader(os.Stdin)
resp, readErr := reader.ReadString('\n')
resp = strings.TrimSpace(resp)
Expand Down
17 changes: 11 additions & 6 deletions data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -4363,9 +4363,14 @@ func (cx *EvalContext) mutableAccountReference(account stackValue) (basics.Addre
if accountIdx > uint64(len(cx.txn.Txn.Accounts)) {
// There was no error, but accountReference has signaled that accountIdx
// is not for mutable ops (because it can't encode it in EvalDelta)
// This also tells us that account.address() will work.
acctAddr, _ := account.address()
err = fmt.Errorf("invalid Account reference for mutation %s", acctAddr)
if cx.version < sharedResourcesVersion {
return basics.Address{}, 0, fmt.Errorf("invalid Account reference for mutation %s", addr)
}
// fall through, which means that starting in v9, the accountIdx
// returned can be > len(tx.Accounts). It will end up getting passed to
// GetLocal, which can record that index in order to produce old-style
// EDS. But those EDs are only made in old consenus versions - at that
// point v9 did not exist, so no backward incompatible change occurs.
}
return addr, accountIdx, err
}
Expand Down Expand Up @@ -5611,9 +5616,9 @@ func opItxnSubmit(cx *EvalContext) (err error) {
}

// Can't call old versions in inner apps.
v, _, verErr := transactions.ProgramVersion(program)
if verErr != nil {
return verErr
calledVersion, _, err = transactions.ProgramVersion(program)
if err != nil {
return err
}
if calledVersion < cx.Proto.MinInnerApplVersion {
return fmt.Errorf("inner app call with version v%d < v%d",
Expand Down
7 changes: 2 additions & 5 deletions ledger/acctdeltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,9 @@ func accountsNewRoundImpl(
// create a new entry.
var ref trackerdb.AccountRef
normBalance := data.newAcct.NormalizedOnlineBalance(proto)
var ref trackerdb.AccountRef
ref, err = writer.InsertAccount(data.address, normBalance, data.newAcct)
if err == nil {
updatedAccounts[updatedAccountIdx].Ref = ref
updatedAccounts[updatedAccountIdx].AccountData = data.newAcct
newAddressesRowIDs[data.address] = ref
if err != nil {
return nil, nil, nil, err
}
updatedAccounts[updatedAccountIdx].Ref = ref
updatedAccounts[updatedAccountIdx].AccountData = data.newAcct
Expand Down
4 changes: 2 additions & 2 deletions ledger/apply/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ func ApplicationCall(ac transactions.ApplicationCallTxnFields, header transactio
if exists {
pass, evalDelta, evalErr := balances.StatefulEval(gi, evalParams, appIdx, params.ClearStateProgram)
if evalErr != nil {
// Fail on non-logic eval errors and ignore LogicEvalError errors
if _, ok := evalErr.(ledgercore.LogicEvalError); !ok {
// ClearStateProgram evaluation can't make the txn fail.
if _, ok := evalErr.(logic.EvalError); !ok {
return evalErr
}
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.