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

fix: solidity coding style #843

Merged

Conversation

NicolasRampoldi
Copy link
Contributor

@NicolasRampoldi NicolasRampoldi commented Aug 22, 2024

Description

  • Adds solhint linter to the CI. To run solhint locally, go to contracts, run npm install and then npm run lint:sol. The CI will run the linter but won't stop the user from pushing to main, it just lists the warnings.
  • Fixes most linter warnings, the ones left don't seem relevant.
  • The three rules added were taken from https://github.com/lambdaclass/era-contracts/blob/main/.solhint.json and it made sense to add them to this repo too.
  • Add make lint_contracts to makefile

To Test

  • Try deploying and test normal flow.
  • Make some errors on purpose to see if the refactoring of requires to custom errors works properly.

@NicolasRampoldi NicolasRampoldi linked an issue Aug 22, 2024 that may be closed by this pull request
@NicolasRampoldi NicolasRampoldi self-assigned this Aug 22, 2024
Copy link

github-actions bot commented Aug 22, 2024

Changes to gas cost

Generated at commit: bc78cc93f7fa31d0ab2ff3a1fbc79cadd9a20962, compared to commit: 19e76e0f07a383afcba000953afed50d8ae10964

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager createNewTask -27 ✅ -0.05%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 4,359,036 (-46,214) createNewTask 51,138 (0) 0.00% 51,319 (-27) -0.05% 51,234 (-12) -0.02% 51,936 (0) 0.00% 256 (0)

@NicolasRampoldi NicolasRampoldi linked an issue Aug 22, 2024 that may be closed by this pull request
…ations

# Conflicts:
#	contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
#	contracts/src/core/AlignedLayerServiceManager.sol
Copy link
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

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

.

Copy link
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

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

Everything seems to be working fine, and read it over for quite some time, but we should talk about this PR because it is pretty big and potentially dangerous.

I used to like a lot the require statements, but custom errors are pretty powerful, mainly because of accepting parameters. More info on this: https://soliditylang.org/blog/2021/04/21/custom-errors/

It looks like it should be compatible with an upgrade, with no need of changing the GAP, but this should be tested more in detail just in case.

Also, should errors be declared in the Interface? While we're at it, Events could also be declared in the Interface.

Also I believe this PR should require at least 3 or even 4 approves.

Finally, a make target to run solhint should come in pretty handy.

…ations

# Conflicts:
#	contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
#	contracts/src/core/AlignedLayerServiceManagerStorage.sol
Copy link
Contributor

@taturosati taturosati left a comment

Choose a reason for hiding this comment

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

Code lgtm, worked in my machine

…ations

# Conflicts:
#	contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
#	contracts/src/core/BatcherPaymentService.sol
…ations

# Conflicts:
#	contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
#	contracts/src/core/AlignedLayerServiceManager.sol
#	contracts/src/core/BatcherPaymentService.sol
@NicolasRampoldi NicolasRampoldi merged commit c26f1ee into main Aug 26, 2024
3 checks passed
@NicolasRampoldi NicolasRampoldi deleted the 835-fix-solidity-coding-style-guideline-violations branch August 26, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: Unused Imports fix: Solidity Coding Style Guideline Violations
4 participants