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

feat(submitter): add GasPriceTTL #3474

Closed
wants to merge 2 commits into from
Closed

feat(submitter): add GasPriceTTL #3474

wants to merge 2 commits into from

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Dec 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option for gas price management with the GasPriceTTL field.
    • Added a method to retrieve the GasPriceTTL value for specific chains.
    • Implemented a TTL check for gas prices in the transaction submission process.
  • Bug Fixes

    • Enhanced error handling and logging for gas price suggestions from the RPC endpoint.
  • Documentation

    • Updated documentation to reflect new configuration options and methods.

@dwasse dwasse requested a review from trajan0x as a code owner December 20, 2024 18:43
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

The pull request introduces a new GasPriceTTL configuration option for managing gas prices in the Ethereum transaction submitter. A new field is added to the ChainConfig struct to specify the duration after which a previous gas price becomes invalid. Corresponding methods are implemented in the configuration and submitter components to handle this TTL (time-to-live) mechanism, allowing more dynamic and flexible gas price management during transaction submissions.

Changes

File Change Summary
ethergo/submitter/config/config.go - Added GasPriceTTL time.Duration field to ChainConfig struct
- Implemented GetGasPriceTTL method to retrieve gas price TTL
ethergo/submitter/config/iconfig_generated.go - Added GetGasPriceTTL(chainID int) time.Duration method to IConfig interface
ethergo/submitter/submitter.go - Enhanced bumpGasFromPrevTx method with TTL check
- Improved gas price handling logic
- Updated applyGasFromOracle method with better error handling and logging

Sequence Diagram

sequenceDiagram
    participant Config as Configuration
    participant Submitter as Transaction Submitter
    participant Oracle as Gas Price Oracle

    Config->>Submitter: Configure GasPriceTTL
    Submitter->>Submitter: Check Previous Tx Timestamp
    alt TTL Exceeded
        Submitter->>Oracle: Fetch New Gas Price
        Oracle-->>Submitter: Return Gas Price
        Submitter->>Submitter: Update Transaction Gas Parameters
    end
Loading

Possibly related PRs

Suggested labels

go, needs-go-generate-services/explorer, size/xs, needs-go-generate-committee, needs-go-generate-sin-executor

Suggested reviewers

  • trajan0x

Poem

🐰 Hopping through the Ethereum lane,
Gas prices dance, no longer plain!
TTL ticks, a rabbit's delight,
Transactions flow with pricing might!
Code hops forward, smart and clean 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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>, 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 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.

@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Dec 20, 2024
Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 82544fc
Status: ✅  Deploy successful!
Preview URL: https://2f262d90.sanguine-fe.pages.dev
Branch Preview URL: https://feat-gas-price-ttl.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 5.00000% with 19 lines in your changes missing coverage. Please review.

Project coverage is 34.06772%. Comparing base (40cd70b) to head (82544fc).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
ethergo/submitter/submitter.go 7.14286% 12 Missing and 1 partial ⚠️
ethergo/submitter/config/config.go 0.00000% 6 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3474         +/-   ##
===================================================
+ Coverage   34.04255%   34.06772%   +0.02517%     
===================================================
  Files            388         388                 
  Lines          24581       24601         +20     
===================================================
+ Hits            8368        8381         +13     
- Misses         15472       15482         +10     
+ Partials         741         738          -3     
Flag Coverage Δ
cctp-relayer 31.97848% <ø> (ø)
ethergo 47.36496% <5.00000%> (+0.00694%) ⬆️
omnirpc 32.65401% <ø> (ø)
opbot 0.18282% <ø> (ø)
promexporter 6.81642% <ø> (ø)
scribe 18.24614% <ø> (+0.06432%) ⬆️
tools 30.31250% <ø> (ø)

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
ethergo/submitter/config/iconfig_generated.go (1)

36-37: Consider describing the TTL behavior more exhaustively.

These lines successfully add the GetGasPriceTTL method to the IConfig interface. You may want to add a doc comment describing expected usage and edge-case handling (e.g., TTL = 0).

ethergo/submitter/config/config.go (1)

231-239: Add tests covering edge cases for GetGasPriceTTL.

The static analysis flags these lines (232–237) as uncovered. Ensure coverage for:
• Retrieving a chain-specific TTL.
• Falling back to the global TTL.
• Zero and non-zero TTL values.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 232-237: ethergo/submitter/config/config.go#L232-L237
Added lines #L232 - L237 were not covered by tests

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40cd70b and 82544fc.

📒 Files selected for processing (3)
  • ethergo/submitter/config/config.go (2 hunks)
  • ethergo/submitter/config/iconfig_generated.go (1 hunks)
  • ethergo/submitter/submitter.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
ethergo/submitter/config/config.go

[warning] 232-237: ethergo/submitter/config/config.go#L232-L237
Added lines #L232 - L237 were not covered by tests

ethergo/submitter/submitter.go

[warning] 514-525: ethergo/submitter/submitter.go#L514-L525
Added lines #L514 - L525 were not covered by tests

🔇 Additional comments (2)
ethergo/submitter/submitter.go (1)

511-525: Ensure test coverage and verify concurrency safety.

The new GasPriceTTL logic in lines 514–525 is missing test coverage (per the static analysis hint). Please consider:

  1. Adding unit tests to validate behavior when TTL is exceeded versus not exceeded.
  2. Verifying that mutating the timestamp on prevTx (prevTx.SetTime(currentTime)) is concurrency-safe if outside processes or threads might also access that struct.

Would you like me to generate sample tests or concurrency analysis scripts as a follow-up?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 514-525: ethergo/submitter/submitter.go#L514-L525
Added lines #L514 - L525 were not covered by tests

ethergo/submitter/config/config.go (1)

52-53: Validate default and custom TTL values.

The new GasPriceTTL field effectively configures how long a gas price can remain valid. Confirm that default or zero values do not lead to unexpected gas pricing behavior.

Copy link

github-actions bot commented Jan 4, 2025

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jan 4, 2025
@github-actions github-actions bot closed this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant