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(protocol): fix inconsistent named variables in function returns #16162

Closed
wants to merge 8 commits into from

Conversation

adaki2004
Copy link
Contributor

@adaki2004 adaki2004 commented Feb 28, 2024

For me the pre-finding is a bit ambiguous. First (by the title) it suggests inconsistent use of named returns but also says "same return style in all of it is functions”, later the last sentence says “Consider being consistent with the use of named returns throughout the codebase.”, which also means (imo) that it is about named variables only (and not applicable where we don’t have a named variable in the returns).


so it can signal:

  • Use the same naming convention (variable vs. _variable everywhere)
  • Either use named variables (everywhere) or not use them (at all)


For me, the former makes more sense, since the latter would result in function body logic changes - a very simple example of that is: TestnetTierProvider getMinTier() -> If we are about to use named variables here, we should modify the if clause to be an if else clause, or adding extra return value to the if, otherwise the flow changes

So I tried to follow the former bullet point to make them consistent:

  • Now, we do not use named variables where do not necessarily need them (e.g.: SgxVerifier addInstances() or SignalService sendSignal() ) And it also helps avoid adding new code logic (e.g.: TestnetTierProvider getMinTier() -> If we are about to use named variables here, we should modify the if clause to be an if else clause, or adding extra return value to the if, otherwise the flow changes)
  • Where the return value is a tuple and one is named, the other is not, then decide based on practicality to either remove the naming, or add the name to the other unnamed variable. (E.g.: _verifyQEReportWithIdentity)
  • To reach consistency across all named variables, r is applied as a prefix. Sometimes we had _variable (to not shadow other vars) and sometimes variable only but according to Solidity styling guide, _ shall be only used for private or internal state variables and non-external functions.
kép

@dantaik dantaik changed the title chore(protocol): Inconsistent named variables in function returns chore(protocol): fix inconsistent named variables in function returns Feb 28, 2024
@adaki2004
Copy link
Contributor Author

@davidtaikocha could you please check the failing genesis tests root cause ? I have no idea how these changes can cause failing them and i even reverted them to see if the renaming caused it, but seemingly not.
kép

@dantaik
Copy link
Contributor

dantaik commented Feb 28, 2024

I don't like the "rReturn" approach. Can we have the following convention:

function (type param) returns (type returnVal)

}

@adaki2004
Copy link
Contributor Author

I don't like the "rReturn" approach. Can we have the following convention:

function (type param) returns (type returnVal)

}

So you mean having return prefix instead of r prefix ?

@dantaik
Copy link
Contributor

dantaik commented Feb 28, 2024

Prefer this approach #16168, but I don't want to cause the relayer to change a lot of code again. So I'm not sure we should merge this BIG PR.

@dantaik dantaik closed this Feb 29, 2024
@dantaik dantaik deleted the inconsistent_return_names branch March 1, 2024 09:30
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.

3 participants