safe-global / safe-smart-account

Safe allows secure management of blockchain assets.
https://safe.global
GNU Lesser General Public License v3.0
1.88k stars 927 forks source link

Fix compilation issue with solidity versions >= 0.8.12 #772

Closed akshay-ap closed 4 months ago

akshay-ap commented 4 months ago

Fixes: #735 and #773

Changes in PR

Codesize increase by 33 bytes with compiler version 0.7.6

This PR:

Safe 21814 bytes (limit is 24576)
SafeL2 22632 bytes (limit is 24576)

Main branch

Safe 21781 bytes (limit is 24576)
SafeL2 22623 bytes (limit is 24576)

Impact on gas usage with Safe contract

Changes in this PR add additional overhead of 49 gas

This PR:

·------------------------------------------------------------|----------------------------|-------------|------------------------------·
|                    Solc version: 0.7.6                     ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 100000000 gas  │
·····························································|····························|·············|·······························
|  Methods                                                                                                                             │
·····················|·······································|·············|··············|·············|···············|···············
|  Contract          ·  Method                               ·  Min        ·  Max         ·  Avg        ·  # calls      ·  usd (avg)   │
·····················|·······································|·············|··············|·············|···············|···············
|  Safe              ·  execTransactionFromModule            ·      51630  ·      184223  ·     127865  ·           11  ·           -  │
·····················|·······································|·············|··············|·············|···············|···············
|  Safe              ·  execTransactionFromModuleReturnData  ·      52273  ·      183979  ·     107919  ·            5  ·           -  │

Main branch

·------------------------------------------------------------|----------------------------|-------------|------------------------------·
|                    Solc version: 0.7.6                     ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 100000000 gas  │
·····························································|····························|·············|·······························
|  Methods                                                                                                                             │
·····················|·······································|·············|··············|·············|···············|···············
|  Safe              ·  execTransactionFromModule            ·      51581  ·      184186  ·     127818  ·           11  ·           -  │
·····················|·······································|·············|··············|·············|···············|···············
|  Safe              ·  execTransactionFromModuleReturnData  ·      52224  ·      183930  ·     107870  ·            5  ·           -  │

Why this approach?

Alternatives considered A.

B.

Side note:

Why event SafeModuleTransaction is not emitted by execTransactionFromModuleReturnData in SafeL2? Why SafeL2 does not override execTransactionFromModuleReturnData. -> execTransactionFromModuleReturnData in SafeL2 should also emit event. Might have been missed in the past. Would be covered in a separate PR.. This PR fixes the issue.

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9646938946

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9660691754

Details


Totals Coverage Status
Change from base Build 9462835574: 0.01%
Covered Lines: 389
Relevant Lines: 401

💛 - Coveralls
coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9660962226

Details


Totals Coverage Status
Change from base Build 9462835574: 0.01%
Covered Lines: 389
Relevant Lines: 401

💛 - Coveralls
mmv08 commented 4 months ago

Why event SafeModuleTransaction is not emitted by execTransactionFromModuleReturnData in SafeL2?

I think because previously execTransactionFromModuleReturnData used to call execTransactionFromModule internally but with the introduction of guards it couldn't rely on the return data buffer anymore and this was changed and overlooked in https://github.com/safe-global/safe-smart-account/pull/728

mmv08 commented 4 months ago

good catch sir! would be great to add a test for this

akshay-ap commented 4 months ago

good catch sir! would be great to add a test for this

Already added in the PR here: https://github.com/safe-global/safe-smart-account/pull/774/files

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9664189214

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
nlordell commented 4 months ago

Do we have some analysis on the gas cost implications of this change?

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9665699454

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9665717420

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
akshay-ap commented 4 months ago

Do we have some analysis on the gas cost implications of this change?

Added it in PR description.

nlordell commented 4 months ago

I also noticed that this implementation started emitting events for execTransactionFromModuleReturnData, so we should add tests for it as @mmv08 suggested.

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9675853335

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
akshay-ap commented 4 months ago

I also noticed that this implementation started emitting events for execTransactionFromModuleReturnData, so we should add tests for it as @mmv08 suggested.

Added here: https://github.com/safe-global/safe-smart-account/pull/772/commits/4e719c27da667004d87ba8ee99fa0bc76e7c2f7b

Now, we don't need #774

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9675916114

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
akshay-ap commented 4 months ago

I'm not sure I understand this "con" from option B in the PR description:

aah, my bad. I have updated the description.

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9676182437

Details


Totals Coverage Status
Change from base Build 9462835574: 0.0%
Covered Lines: 388
Relevant Lines: 400

💛 - Coveralls
coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9676677224

Details


Totals Coverage Status
Change from base Build 9462835574: 0.01%
Covered Lines: 389
Relevant Lines: 401

💛 - Coveralls
coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 9676677615

Details


Totals Coverage Status
Change from base Build 9462835574: 0.01%
Covered Lines: 389
Relevant Lines: 401

💛 - Coveralls