synapsecns / sanguine

Synapse Monorepo
MIT License
43 stars 31 forks source link

fix(contracts-rfq): gas estimation tests [SLT-275] #3204

Closed ChiTimesChi closed 2 months ago

ChiTimesChi commented 2 months ago

Description Introduces a separate set of tests meant for accurate average gas estimation.

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

Walkthrough

The pull request introduces significant updates to the Solidity testing framework, particularly for the FastBridgeV2 contract. It modifies the GitHub Actions workflow for gas reporting, introduces new test contracts for benchmarking gas usage, and refactors existing test contracts to streamline functionality. The changes focus on enhancing the accuracy of gas cost estimations and improving the structure of the testing codebase.

Changes

File Path Change Summary
.github/workflows/solidity.yml Modified the GitHub Actions workflow to change the command for running tests and generating gas reports, focusing on a specific benchmark test instead of excluding failing tests.
packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol Introduced FastBridgeV2DstBaseTest with methods for setup, deployment, and token minting, along with relay functions.
packages/contracts-rfq/test/FastBridgeV2.Dst.t.sol Refactored FastBridgeV2DstTest to inherit from FastBridgeV2DstBaseTest, removing several methods and constants to streamline the contract.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.t.sol Added a gas benchmarking contract for destination chain functions, including test functions for evaluating gas costs associated with relaying tokens and ETH.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol Introduced FastBridgeV2GasBenchmarkSrcProtocolFeesTest, overriding functions to set up protocol fee configurations and transaction parameters.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol Created a comprehensive gas benchmarking test suite for source chain functions, including setup, transaction fixture creation, and multiple test functions for gas costs and functionality.
packages/contracts-rfq/test/FastBridgeV2.Src.Base.t.sol Introduced FastBridgeV2SrcBaseTest with constants, setup methods, and helper functions for bridging operations, enhancing the testing capabilities of the FastBridgeV2 contract.
packages/contracts-rfq/test/FastBridgeV2.Src.t.sol Refactored FastBridgeV2SrcTest to inherit from FastBridgeV2SrcBaseTest, removing several constants and functions, indicating a shift in the testing approach for bridging functionalities.

Possibly related PRs

Suggested labels

M-ci, size/m, M-contracts, needs-go-generate-services/rfq

Suggested reviewers

Poem

πŸ‡ In the meadow where bunnies play,
New tests hop in, brightening the day!
Gas reports dance, with numbers so neat,
FastBridge flows, a testing feat!
With each little change, we leap and bound,
In the world of Solidity, joy is found! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
πŸͺ§ Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 2 months ago

Changes to gas cost

Generated at commit: dc091ceecf618707e72228d3c18ce6dfbbb1d2b7, compared to commit: 257e57c702c97ec6314390930609725e023848c2

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 bridge
bridgeStatuses
claim(bytes)
claim(bytes,address)
protocolFees
relay(bytes)
relay(bytes,address)
-10,935 βœ…
+571 ❌
-9,794 βœ…
-8,320 βœ…
-699 βœ…
-9,613 βœ…
-20,402 βœ…
-12.18%
+98.11%
-15.97%
-13.54%
-37.91%
-11.95%
-22.26%

Full diff report πŸ‘‡
| Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) | |:-|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|-:| | **FastBridgeV2** | 2,348,531 (0) | _bridge_
_bridgeStatuses_
_claim(bytes)_
_claim(bytes,address)_
_dispute_
_grantRole_
_protocolFees_
_prove(bytes,bytes32)_
_prove(bytes32,bytes32,address)_
_refund_
_relay(bytes)_
_relay(bytes,address)_
_setProtocolFeeRate_ | 63,840 (0)
582 (0)
43,982 (-2,500)
46,853 (+3,047)
31,654 (0)
101,383 (+74,599)
645 (0)
56,896 (+420)
54,315 (+204)
46,057 (+2,941)
64,902 (+36,567)
65,341 (-25,000)
47,399 (+23,396) | **0.00%**
**0.00%**
**-5.38%**
**+6.96%**
**0.00%**
**+278.52%**
**0.00%**
**+0.74%**
**+0.38%**
**+6.82%**
**+129.05%**
**-27.67%**
**+97.47%** | 78,818 (-10,935)
1,153 (+571)
51,516 (-9,794)
53,137 (-8,320)
31,663 (+4)
114,680 (+7,216)
1,145 (-699)
56,924 (-32)
54,326 (+32)
49,763 (-13)
70,797 (-9,613)
71,236 (-20,402)
47,399 (+845) | **-12.18%**
**+98.11%**
**-15.97%**
**-13.54%**
**+0.01%**
**+6.71%**
**-37.91%**
**-0.06%**
**+0.06%**
**-0.03%**
**-11.95%**
**-22.26%**
**+1.82%** | 74,673 (-27,669)
582 (0)
51,525 (-9,794)
53,146 (-17,850)
31,666 (+12)
118,483 (+12)
645 (-2,000)
56,926 (+6)
54,327 (+12)
49,772 (+1,656)
70,797 (-16,164)
71,236 (-19,105)
47,399 (0) | **-27.04%**
**0.00%**
**-15.97%**
**-25.14%**
**+0.04%**
**+0.01%**
**-75.61%**
**+0.01%**
**+0.02%**
**+3.44%**
**-18.59%**
**-21.15%**
**0.00%** | 102,607 (-19,895)
2,582 (+2,000)
59,033 (-17,088)
59,404 (-17,720)
31,666 (0)
118,483 (0)
2,645 (0)
57,040 (0)
54,327 (0)
53,451 (0)
76,693 (-31,867)
77,132 (-17,100)
47,399 (0) | **-16.24%**
**+343.64%**
**-22.45%**
**-22.98%**
**0.00%**
**0.00%**
**0.00%**
**0.00%**
**0.00%**
**0.00%**
**-29.35%**
**-18.15%**
**0.00%** | 132 (-4,583)
224 (-2,926)
4 (-1,020)
4 (-1,039)
4 (-10)
144 (-359)
256 (-3,506)
36 (-2,048)
36 (+20)
8 (-1,034)
2 (-7)
2 (-1)
16 (-32) |
cloudflare-workers-and-pages[bot] commented 2 months ago

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 129cde2
Status: βœ…  Deploy successful!
Preview URL: https://11498d1f.sanguine-fe.pages.dev
Branch Preview URL: https://fix-gas-estimation-tests.sanguine-fe.pages.dev

View logs

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.94584%. Comparing base (f0b13bc) to head (129cde2). Report is 10 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3204 +/- ## ==================================================== + Coverage 40.97804% 90.94584% +49.96780% ==================================================== Files 459 60 -399 Lines 25643 1237 -24406 Branches 343 148 -195 ==================================================== - Hits 10508 1125 -9383 + Misses 14383 109 -14274 + Partials 752 3 -749 ``` | [Flag](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | Coverage Ξ” | | |---|---|---| | [cctp-relayer](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [core](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [ethergo](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [git-changes-action](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [omnirpc](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [opbot](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [packages](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `90.56974% <ΓΈ> (ΓΈ)` | | | [screener-api](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [scribe](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [solidity](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `92.69406% <ΓΈ> (-2.01267%)` | :arrow_down: | | [tools](https://app.codecov.io/gh/synapsecns/sanguine/pull/3204/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.