synapsecns / sanguine

Synapse Monorepo
MIT License
43 stars 31 forks source link

test(contracts-rfq): gas benchmark for the arbitrary call [SLT-233] #3273

Closed ChiTimesChi closed 1 month ago

ChiTimesChi commented 1 month ago

Description

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago

Walkthrough

This pull request introduces several changes across multiple Solidity test files related to the FastBridgeV2 contract. Key updates include the addition of new test contracts for benchmarking gas overhead associated with arbitrary calls, renaming existing contracts for consistency, and modifications to functions that manage transaction parameters and nonce values. The changes enhance the testing framework to better simulate real-world scenarios and ensure proper functionality of the FastBridgeV2 contract.

Changes

File Path Change Summary
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol Added contract FastBridgeV2GasBenchmarkDstArbitraryCallTest with overridden setUp and createFixturesV2 methods.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol Renamed contracts and updated createFixturesV2 to call super.createFixturesV2().
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.t.sol Renamed contract from FastBridgeV2DstGasBenchmarkTest to FastBridgeV2GasBenchmarkDstTest.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Encoding.t.sol Renamed contract to FastBridgeV2GasBenchmarkEncodingTest and added test_getBridgeTransactionV2_withArbitraryCall method.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol Added contract FastBridgeV2GasBenchmarkSrcArbitraryCallTest with overridden createFixturesV2 method.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol Updated configureFastBridge to set protocol fee rate to 1% and adjusted createFixtures.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol Modified nonce assignments and refactored test functions for bridging tokens and ETH.
packages/contracts-rfq/test/FastBridgeV2.t.sol Added cheatSenderNonce function to manipulate sender's nonce.

Possibly related PRs

Suggested labels

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

Suggested reviewers

πŸ‡ In the realm of code, we leap and bound,
With tests and functions, new paths are found.
Gas benchmarks soaring, like rabbits in flight,
In the world of Solidity, we code through the night! πŸŒ™βœ¨


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](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

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

Project coverage is 32.29410%. Comparing base (2b05e51) to head (c4393fc). Report is 12 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3273 +/- ## =================================================== + Coverage 30.68788% 32.29410% +1.60622% =================================================== Files 447 433 -14 Lines 29787 28739 -1048 Branches 82 155 +73 =================================================== + Hits 9141 9281 +140 + Misses 19797 18612 -1185 + Partials 849 846 -3 ``` | [Flag](https://app.codecov.io/gh/synapsecns/sanguine/pull/3273/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | Coverage Ξ” | | |---|---|---| | [packages](https://app.codecov.io/gh/synapsecns/sanguine/pull/3273/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `90.43902% <ΓΈ> (ΓΈ)` | | | [promexporter](https://app.codecov.io/gh/synapsecns/sanguine/pull/3273/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/3273/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `93.82716% <ΓΈ> (?)` | | 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.

cloudflare-workers-and-pages[bot] commented 1 month ago

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: c4393fc
Status: βœ…  Deploy successful!
Preview URL: https://03d6c40a.sanguine-fe.pages.dev
Branch Preview URL: https://test-fbv2-arbitrary-call-gas.sanguine-fe.pages.dev

View logs

github-actions[bot] commented 1 month ago

Changes to gas cost

Generated at commit: 53d53a2ccac0268cf6560489d3c3abb40c2454b7, compared to commit: 6dd94ca5c4e9c8ec1263940d7ffff78096d90b2b

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 getBridgeTransactionV2
relay(bytes)
relay(bytes,address)
+147 ❌
+1,653 ❌
+1,653 ❌
+3.49%
+2.34%
+2.33%

Full diff report πŸ‘‡
| Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) | |:-|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|-:| | **FastBridgeV2** | 2,870,712 (0) | _claim(bytes)_
_claim(bytes,address)_
_getBridgeTransactionV2_
_grantRole_
_prove(bytes,bytes32)_
_prove(bytes32,bytes32,address)_
_refund_
_relay(bytes)_
_relay(bytes,address)_ | 43,909 (0)
46,762 (0)
4,214 (0)
101,405 (0)
35,595 (+12)
32,104 (-12)
47,669 (0)
64,685 (0)
65,102 (0) | **0.00%**
**0.00%**
**0.00%**
**0.00%**
**+0.03%**
**-0.04%**
**0.00%**
**0.00%**
**0.00%** | 50,936 (-527)
52,539 (-527)
4,361 (+147)
114,536 (-135)
35,908 (+298)
32,139 (0)
51,742 (+347)
72,263 (+1,653)
72,680 (+1,653) | **-1.02%**
**-0.99%**
**+3.49%**
**-0.12%**
**+0.84%**
**0.00%**
**+0.68%**
**+2.34%**
**+2.33%** | 51,472 (0)
53,075 (0)
4,361 (+147)
118,505 (0)
35,619 (+6)
32,140 (0)
51,903 (+499)
72,174 (+1,564)
72,591 (+1,564) | **0.00%**
**0.00%**
**+3.49%**
**0.00%**
**+0.02%**
**0.00%**
**+0.97%**
**+2.21%**
**+2.20%** | 59,000 (0)
59,353 (0)
4,508 (+294)
118,505 (0)
36,571 (+844)
32,140 (0)
56,137 (+1,033)
82,727 (+6,192)
83,144 (+6,192) | **0.00%**
**0.00%**
**+6.98%**
**0.00%**
**+2.36%**
**0.00%**
**+1.87%**
**+8.09%**
**+8.05%** | 6 (+2)
6 (+2)
2 (+1)
263 (+80)
63 (+21)
63 (+21)
12 (+4)
6 (+4)
6 (+4) |