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

Submitter: only bump gas price for transactions with current nonce #2417

Closed
wants to merge 5 commits into from

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Apr 1, 2024

Description
Only supply a prevTx to setGasPrice() in the case we are on the current nonce. This should help conserve "gas expenditure" as far as mempool processing is concerned.

Metadata

Summary by CodeRabbit

  • Refactor
    • Improved transaction submission efficiency by conditionally adjusting gas prices.
  • Tests
    • Updated test expectations to align with new transaction submission logic.
  • New Features
    • Added functionality to deploy RFQ to Base network.
    • Introduced a new smart contract FastBridge with various transaction bridging functions.
    • Enhanced relayer options management for transaction submission.
    • Configured relayer behavior through new variadic arguments.
  • Documentation
    • Updated foundry.toml config file with new fields for base network.
  • Chores
    • Updated FastBridge contract version to 0.2.0.
    • Added configurations for base network in deployment scripts.
  • Bug Fixes
    • Fixed import statements in synapse.go for accurate contract references.
    • Corrected parameter passing in startCCTPRelayer function for proper relayer configuration.

@dwasse dwasse requested a review from trajan0x as a code owner April 1, 2024 21:43
Copy link
Contributor

coderabbitai bot commented Apr 1, 2024

Walkthrough

The recent updates focus on refining gas price management for Ethereum transactions. Changes include introducing a parameter for adjusting gas prices based on transaction nonce and modifying test expectations for the SuggestGasPrice function, emphasizing improved gas price determination during transaction submissions.

Changes

File Summary
ethergo/.../chain_queue.go Added a boolean parameter in bumpTX for conditional gas price adjustment based on nonce.
ethergo/.../submitter_test.go Updated expected invocations of SuggestGasPrice from 2 to 3 in SubmitterSuite.
packages/contracts-rfq/.../CHANGELOG.md
packages/contracts-rfq/deployments/base/.chainId
packages/contracts-rfq/deployments/base/FastBridge.json
packages/contracts-rfq/.../package.json
Version 0.2.0 introduces RFQ deployment to Base with new features in FastBridge contracts.
packages/contracts-rfq/.../foundry.toml Added base field in [rpc_endpoints] and [etherscan] sections.
packages/contracts-rfq/.../script/fb-config.sh
packages/contracts-rfq/.../script/fb-deploy.sh
Added commands for configuring and deploying FastBridge on the base network.
services/cctp-relayer/relayer/options.go
services/cctp-relayer/relayer/relayer.go
Introduced functionality for managing relayer options.
services/rfq/relayer/inventory/synapse.go Updated import statements for relayer contracts.

🐰✨
In the land of code and ether,
Where gas prices dance and sway,
The rabbit fine-tuned the numbers,
Ensuring transactions play.
Thrice the check, for smoother deals,
With changes that set sails.
🌟🚀🐇

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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@dwasse dwasse changed the title Only bump gas price for transactions with current nonce Submitter: only bump gas price for transactions with current nonce Apr 1, 2024
@github-actions github-actions bot added go Pull requests that update Go code size/xs labels Apr 1, 2024
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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 9ed2dd0 and 1256026.
Files selected for processing (2)
  • ethergo/submitter/chain_queue.go (3 hunks)
  • ethergo/submitter/submitter_test.go (1 hunks)
Additional Context Used
Additional comments not posted (3)
ethergo/submitter/chain_queue.go (2)

87-92: The logic to conditionally bump the gas price based on the current nonce of the transaction is clear and aligns with the PR's objective. However, ensure that the currentNonce variable accurately reflects the latest nonce at the time of this operation, considering potential race conditions or updates that may occur in a multi-threaded environment.


176-186: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [152-183]

The modification to the bumpTX function, introducing a bumpGasPrice boolean to control whether the gas price should be bumped, is a sensible approach to optimize gas expenditure. However, consider the following points for improvement and verification:

  1. Error Handling: Ensure comprehensive error handling within this function, especially for external calls like getGasEstimate, GetTransactor, and setGasPrice. It appears to be handled well, but double-check that all possible error scenarios are covered.
  2. Gas Price Calculation Logic: The logic to decide whether to bump the gas price or not (prevTx = nil if !bumpGasPrice) is straightforward. However, verify that this approach does not introduce any edge cases where a transaction might get stuck due to insufficient gas price in a rapidly changing gas price environment.
  3. Testing: It's crucial to have extensive tests covering various scenarios, including edge cases where the gas price fluctuates significantly. Ensure that tests cover the new logic introduced for handling bumpGasPrice.
ethergo/submitter/submitter_test.go (1)

47-47: The adjustment in the expected number of invocations for the SuggestGasPrice function from Twice() to 3 is consistent with the changes made in the chain_queue.go file. This reflects an understanding of how the modified logic affects the behavior of the system under test. However, ensure that this change is accompanied by a comprehensive test case that specifically validates the new behavior introduced in the PR, including scenarios where transactions have the current nonce and where they do not.

Copy link

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

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0bd0e22
Status: ✅  Deploy successful!
Preview URL: https://f39e0a3f.sanguine-fe.pages.dev
Branch Preview URL: https://feat-bump-current-nonce.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

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

Project coverage is 46.58246%. Comparing base (813de8e) to head (0bd0e22).
Report is 96 commits behind head on master.

Files Patch % Lines
ethergo/submitter/chain_queue.go 27.27273% 7 Missing and 1 partial ⚠️
ethergo/chain/gas/cmp.go 0.00000% 7 Missing ⚠️
ethergo/submitter/submitter.go 75.00000% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2417         +/-   ##
===================================================
- Coverage   46.72382%   46.58246%   -0.14137%     
===================================================
  Files            396         406         +10     
  Lines          30447       30797        +350     
  Branches          83         132         +49     
===================================================
+ Hits           14226       14346        +120     
- Misses         14691       14922        +231     
+ Partials        1530        1529          -1     
Flag Coverage Δ
cctp-relayer 43.53414% <ø> (ø)
committee 63.04654% <ø> (+0.84626%) ⬆️
omnirpc 53.23194% <ø> (ø)
promexporter 75.91241% <ø> (?)
rfq 29.09708% <ø> (ø)
sin-executor 61.57635% <ø> (ø)
solidity 53.76344% <ø> (?)
stiprelayer 3.33333% <ø> (ø)

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: 1

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 1256026 and 0bd0e22.
Files ignored due to path filters (4)
  • services/cctp-relayer/go.mod is excluded by !**/*.mod
  • services/cctp-relayer/go.sum is excluded by !**/*.sum
  • services/rfq/go.mod is excluded by !**/*.mod
  • services/rfq/go.sum is excluded by !**/*.sum
Files selected for processing (11)
  • packages/contracts-rfq/CHANGELOG.md (1 hunks)
  • packages/contracts-rfq/deployments/base/.chainId (1 hunks)
  • packages/contracts-rfq/deployments/base/FastBridge.json (1 hunks)
  • packages/contracts-rfq/foundry.toml (1 hunks)
  • packages/contracts-rfq/package.json (1 hunks)
  • packages/contracts-rfq/script/fb-config.sh (1 hunks)
  • packages/contracts-rfq/script/fb-deploy.sh (1 hunks)
  • services/cctp-relayer/relayer/options.go (1 hunks)
  • services/cctp-relayer/relayer/relayer.go (2 hunks)
  • services/rfq/relayer/inventory/synapse.go (2 hunks)
  • services/rfq/relayer/service/relayer.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/contracts-rfq/package.json
Additional Context Used
GitHub Check Runs (1)
codecov/patch success (4)

services/cctp-relayer/relayer/options.go: [warning] 14-17: services/cctp-relayer/relayer/options.go#L14-L17
Added lines #L14 - L17 were not covered by tests


services/cctp-relayer/relayer/options.go: [warning] 23-24: services/cctp-relayer/relayer/options.go#L23-L24
Added lines #L23 - L24 were not covered by tests

Additional comments not posted (10)
packages/contracts-rfq/deployments/base/.chainId (1)

1-1: The addition of the chain ID 8453 aligns with the PR objectives of deploying contracts to a new base network. Looks good!

packages/contracts-rfq/script/fb-deploy.sh (1)

17-17: The addition of the deployment command for the base network aligns with the PR objectives and follows bash scripting best practices. Looks good!

packages/contracts-rfq/script/fb-config.sh (1)

18-18: The addition of the configuration command for the base network aligns with the PR objectives and follows bash scripting best practices. Looks good!

packages/contracts-rfq/foundry.toml (1)

21-21: The addition of the base network fields under [rpc_endpoints] and [etherscan] aligns with the PR objectives of supporting a new base network and follows the TOML format correctly. Looks good!

Also applies to: 27-27

packages/contracts-rfq/CHANGELOG.md (1)

6-11: The documentation of the deployment of RFQ to Base in version 0.2.0 accurately reflects the PR's objectives. The changelog is clear and follows conventional commit guidelines. Looks good!

services/rfq/relayer/inventory/synapse.go (1)

6-6: The update in import statements, replacing the explorer contracts import with one for cctp-relayer contracts, aligns with the PR objectives and improves code modularity. Looks good!

services/rfq/relayer/service/relayer.go (1)

277-277: The addition of the relayer.WithSubmitter(r.submitter) parameter to the NewCCTPRelayer function call aligns with the PR objectives and likely enhances the functionality of the CCTP relayer by providing it with a submitter for transactions. Looks good!

services/cctp-relayer/relayer/relayer.go (2)

77-80: The addition of rawOpts ...OptionsArgsOption as a variadic argument in the NewCCTPRelayer function introduces a flexible way to configure the CCTPRelayer. This approach allows for future extensions without changing the function signature. However, ensure that the documentation is updated to reflect this change and provide examples of how to use these options.


117-120: The conditional initialization of txSubmitter based on whether it is provided through opts is a good practice for dependency injection, which can facilitate testing and customization. However, it's crucial to ensure that the default behavior (when txSubmitter is nil) is well-documented and tested to prevent any unexpected behavior.

packages/contracts-rfq/deployments/base/FastBridge.json (1)

1-1219: The FastBridge.json file provides a comprehensive ABI for the FastBridge contract, including functions for bridging, claiming, disputing, and managing roles. Ensure that the contract's implementation aligns with these definitions, especially regarding security and efficiency in gas usage. Additionally, verify that the contract has undergone thorough testing, including unit tests and integration tests, to ensure its correctness and security.

Comment on lines 14 to 17
func WithSubmitter(txSubmitter submitter.TransactionSubmitter) OptionsArgsOption {
return func(options *relayerOptions) {
options.submitter = txSubmitter
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of the WithSubmitter option follows the pattern of options design in Go and aligns with the PR objectives. However, it's recommended to add test coverage for this new functionality to ensure its correctness and maintainability.

Would you like assistance in creating test cases for the new WithSubmitter option?

Base automatically changed from feat/bump-fee-cap to master April 2, 2024 00:17
Copy link

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 Apr 16, 2024
@github-actions github-actions bot closed this Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/l Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants