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: Gas buffer in MessageBus, pack AppConfig in ICAppV1 #2511

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Apr 17, 2024

Description

  • Adds a configurable gas buffer that MessageBus adds on top of gas limit requested by the legacy apps
    • Default value of 20000 is used based on this testnet tx.
  • Improves the Interchain App template by packing the app config fields in a single storage slot.

Summary by CodeRabbit

  • New Features

    • Introduced new public state variables messageLengthEstimate, nonce, and gasBuffer for enhanced control and flexibility.
    • Added functionality to adjust gas buffer settings and calculate gas limits more accurately for interchain messages.
    • Included new events and functions for dynamic system parameter adjustments and monitoring.
  • Improvements

    • Optimized storage variable organization to improve configuration management efficiency.
    • Updated logic for handling system nonces and gas calculations to ensure precise operations.
  • Testing Enhancements

    • Expanded integration and unit tests to cover new features, enhancing system robustness and reliability.

Copy link
Contributor

coderabbitai bot commented Apr 17, 2024

Walkthrough

The recent updates focus on refining gas management and configuration in interchain communication contracts. Changes include introducing new state variables and functions in MessageBus.sol for improved gas handling, updating events and interfaces for enhanced functionality, and refining test cases to ensure proper gas limit calculations and buffer settings.

Changes

Files Changes
.../contracts-communication/contracts/legacy/MessageBus.sol - Introduce new state variables messageLengthEstimate, nonce, and gasBuffer.
- Update logic for nonce and gasBuffer handling.
- Add setGasBuffer function.
- Enhance gas limit calculation with sendGasBuffer parameter.
.../contracts-communication/contracts/legacy/events/MessageBusEvents.sol - Add GasBufferSet event with uint64 parameter.
- Update MessageLengthEstimateSet event to accept uint256 parameter.
.../contracts-communication/contracts/legacy/interfaces/IMessageBus.sol - Include setGasBuffer function for Interchain Governor gas buffer setting.
.../contracts-communication/test/integration/legacy/LegacyPingPong.t.sol - Refactor gas limit constants for app and message bus.
- Calculate new total gas limit as the sum of these values.
.../contracts-communication/test/legacy/MessageBus.Base.t.sol - Define GAS_BUFFER constant for IC_GAS_LIMIT calculation.
- Update icOptions to use IC_GAS_LIMIT instead of MOCK_GAS_LIMIT.
.../contracts-communication/test/legacy/MessageBus.Management.t.sol - Add BUFFER constant of type uint64 with value 12_345.
- Introduce functions for testing gas buffer settings and events.

🐇✨📜✨🐇

In the realm of code, where logic gates swing,

A rabbit hopped by, adjusting the string.

With a tweak and a twist of the gas and the nonce,

Ensuring the messages flow, not even once to flounce.

Oh, celebrate the bytes, for they dance anew,

Under the watchful eyes of the coding crew! 🎉🐇

🐇✨📜✨🐇


Recent Review Details

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between d26fc94 and ce2855b.
Files selected for processing (4)
  • packages/contracts-communication/deployments/arb_sepolia/MessageBus.json (4 hunks)
  • packages/contracts-communication/deployments/arb_sepolia/PingPongApp.json (2 hunks)
  • packages/contracts-communication/deployments/eth_sepolia/MessageBus.json (4 hunks)
  • packages/contracts-communication/deployments/eth_sepolia/PingPongApp.json (2 hunks)
Additional comments not posted (16)
packages/contracts-communication/deployments/eth_sepolia/PingPongApp.json (3)

2-2: Updated contract address to 0x8dA1BEd6ff65C7A8f0459822B52f8d40BbB549a0.


5-6: Updated transaction receipt hash to 0xbd6ad3c6ac55bdc6c1a259cb2cc4d0c51a9aa5b0551eed4636c904ef16204928 and block number to 5719541.


1045-1058: Added new error type SafeCastOverflowedUintDowncast to handle specific overflow conditions in downcasting unsigned integers.

packages/contracts-communication/deployments/arb_sepolia/PingPongApp.json (3)

2-2: Updated contract address to 0x8420DCB8dD1a5eDEa2F71bE26aD275d3fa61F3CF.


5-6: Updated transaction receipt hash to 0x13d399215b2fef40032f26d1f63f9d1f701fd9537e3cbfddec6c145050205a0f and block number to 34689074.


1045-1058: Added new error type SafeCastOverflowedUintDowncast to handle specific overflow conditions in downcasting unsigned integers.

packages/contracts-communication/deployments/eth_sepolia/MessageBus.json (5)

2-2: Updated contract address to 0x8D2F5587f094D97cb6c5607601dDc6b97d486635.


5-6: Updated transaction receipt details: hash to 0x78cf1502a921afcf6b158432b829cd40099efbb59cbc6c485bd72f43acbd55e8 and block number to 5719544.


164-175: Added new function gasBuffer to retrieve the current gas buffer setting. This function is crucial for external callers to understand the additional gas buffer applied to transactions.


604-615: Added new function setGasBuffer allowing the modification of the gas buffer. This function is essential for dynamic adjustments based on network conditions and should be secured appropriately to prevent unauthorized access.


750-761: Introduced new event GasBufferSet which logs changes to the gas buffer. This event aids in tracking adjustments over time and is crucial for auditability.

packages/contracts-communication/deployments/arb_sepolia/MessageBus.json (5)

2-2: Updated contract address to 0x8CeFD8163CaBd9BF67071E68668a959CFC50D5E2.


5-6: Updated transaction receipt details: hash to 0x682484b618db694da7d564f30f320ecb4ea3ebd39f62a2221ad373a208c9a459 and block number to 34689167.


164-175: Added new function gasBuffer to retrieve the current gas buffer setting. This function is crucial for external callers to understand the additional gas buffer applied to transactions.


604-615: Added new function setGasBuffer allowing the modification of the gas buffer. This function is essential for dynamic adjustments based on network conditions and should be secured appropriately to prevent unauthorized access.


750-761: Introduced new event GasBufferSet which logs changes to the gas buffer. This event aids in tracking adjustments over time and is crucial for auditability.


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

cloudflare-workers-and-pages bot commented Apr 17, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: ce2855b
Status: ✅  Deploy successful!
Preview URL: https://2c2596a4.sanguine-fe.pages.dev
Branch Preview URL: https://fix-message-bus-gas-buffer.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.38936%. Comparing base (4aa4ded) to head (ce2855b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2511         +/-   ##
===================================================
+ Coverage   47.05342%   47.38936%   +0.33594%     
===================================================
  Files            384         431         +47     
  Lines          29373       30414       +1041     
  Branches          83         261        +178     
===================================================
+ Hits           13821       14413        +592     
- Misses         14102       14531        +429     
- Partials        1450        1470         +20     
Flag Coverage Δ
packages 90.62500% <ø> (ø)
solidity 56.86840% <100.00000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChiTimesChi ChiTimesChi merged commit 1903930 into master Apr 18, 2024
52 checks passed
@ChiTimesChi ChiTimesChi deleted the fix/message-bus-gas-buffer branch April 18, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant