AthanorLabs / atomic-swap

💫 ETH-XMR atomic swap implementation
GNU Lesser General Public License v3.0
341 stars 44 forks source link

solc optimize contract bytecode #414

Closed noot closed 1 year ago

noot commented 1 year ago

before:

=== RUN   TestSwapCreator_Claim_random
    swap_creator_test.go:245: gas cost to deploy SwapCreator.sol: 1700528
    swap_creator_test.go:262: gas cost to call new_swap: 53086
    swap_creator_test.go:293: gas cost to call SetReady: 33636
    swap_creator_test.go:302: gas cost to call Claim: 46224
--- PASS: TestSwapCreator_Claim_random (8.69s)
=== RUN   TestSwapCreator_Refund_beforeT0
    swap_creator_test.go:333: gas cost to deploy SwapCreator.sol: 1700528
    swap_creator_test.go:348: gas cost to call new_swap: 53086
    swap_creator_test.go:374: gas cost to call Refund: 45964
--- PASS: TestSwapCreator_Refund_beforeT0 (6.69s)

now:

=== RUN   TestSwapCreator_Claim_random
    swap_creator_test.go:245: gas cost to deploy SwapCreator.sol: 1004649
    swap_creator_test.go:262: gas cost to call new_swap: 49833
    swap_creator_test.go:293: gas cost to call SetReady: 31248
    swap_creator_test.go:302: gas cost to call Claim: 42965
--- PASS: TestSwapCreator_Claim_random (8.70s)
=== RUN   TestSwapCreator_Refund_beforeT0
    swap_creator_test.go:333: gas cost to deploy SwapCreator.sol: 1004649
    swap_creator_test.go:348: gas cost to call new_swap: 49833
    swap_creator_test.go:374: gas cost to call Refund: 42724
--- PASS: TestSwapCreator_Refund_beforeT0 (6.66s)

huge improvement w.r.t bytecode size, also improves cost of all calls

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.17 :tada:

Comparison is base (d2629f8) 59.33% compared to head (4b91a1c) 59.51%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #414 +/- ## ========================================== + Coverage 59.33% 59.51% +0.17% ========================================== Files 120 120 Lines 10784 10780 -4 ========================================== + Hits 6399 6416 +17 + Misses 3676 3661 -15 + Partials 709 703 -6 ``` | [Impacted Files](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [ethereum/check\_swap\_creator\_contract.go](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZXRoZXJldW0vY2hlY2tfc3dhcF9jcmVhdG9yX2NvbnRyYWN0Lmdv) | `65.00% <ø> (ø)` | | | [ethereum/deploy\_util.go](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZXRoZXJldW0vZGVwbG95X3V0aWwuZ28=) | `44.56% <ø> (-2.31%)` | :arrow_down: | | [ethereum/swap\_creator.go](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZXRoZXJldW0vc3dhcF9jcmVhdG9yLmdv) | `7.97% <ø> (ø)` | | | [common/config.go](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29tbW9uL2NvbmZpZy5nbw==) | `85.84% <100.00%> (ø)` | | ... and [6 files with indirect coverage changes](https://codecov.io/gh/AthanorLabs/atomic-swap/pull/414/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.