Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

cmd: add --da.grpc.gasprice optional flag #49

Merged
merged 4 commits into from
Jan 11, 2024
Merged

Conversation

tuxcanfly
Copy link
Collaborator

@tuxcanfly tuxcanfly commented Jan 11, 2024

Overview

This PR adds a new cli flag --da.grpc.gasprice that allows the service to configure a global gas price for all blob transactions. It defaults to -1 to use the default fees.

Note that each transaction can override the global gas price by passing in a non-negative gas price to Submit.

Fixes #47

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features

    • Introduced a new gas price configuration option for data availability submissions.
  • Bug Fixes

    • Corrected the initialization of data availability components to properly handle the new gas price parameter.
  • Refactor

    • Updated internal test cases to align with the new gas price functionality.

Copy link

coderabbitai bot commented Jan 11, 2024

Warning

Rate Limit Exceeded

@tuxcanfly has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 47 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 8e29d28 and ebc9e7a.

Walkthrough

The code changes incorporate a new feature that allows setting a global gasPrice for transactions. This update modifies the CelestiaDA struct and related functions to handle a default gasPrice, which can be specified via command-line options and can be overridden in individual Submit requests. This streamlines the configuration process, making it more efficient for clients to interact with the Celestia Data Availability Layer.

Changes

File Pattern Change Summary
celestia/celestia.go Added gasPrice field; updated NewCelestiaDA and Submit
celestia_test.go Modified function calls and test logic for gasPrice
cmd/.../cmd.go Added grpcGasPriceFlag constant; updated function handling
cmd/.../server.go Updated serve function to accept gasPrice parameter

Assessment against linked issues

Objective Addressed Explanation
[#47]: Allow configuring global gasPrice
[#47]: Allow gasPrice to be overridden per request

Poem

In the realm of code, where data flows wide, 🌌
A rabbit hopped in, with a feature stride. 🐇
"Set once, run smooth," it cheerily advised, 🛠️
Now gas prices global, the clients are enticed! 🎉

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8e29d28) 73.02% compared to head (ebc9e7a) 73.88%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
+ Coverage   73.02%   73.88%   +0.85%     
==========================================
  Files           2        2              
  Lines         152      157       +5     
==========================================
+ Hits          111      116       +5     
  Misses         28       28              
  Partials       13       13              

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

@tuxcanfly tuxcanfly marked this pull request as ready for review January 11, 2024 18:36
@tuxcanfly tuxcanfly changed the title cmd: add --da.gasprice optional flag cmd: add --da.grpc.gasprice optional flag Jan 11, 2024
Copy link

@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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0d72059 and 1295a60.
Files selected for processing (5)
  • celestia/celestia.go (3 hunks)
  • celestia/celestia_test.go (2 hunks)
  • celestia_test.go (1 hunks)
  • cmd/celestia-da/cmd.go (4 hunks)
  • cmd/celestia-da/server.go (2 hunks)
Additional comments: 11
cmd/celestia-da/server.go (1)
  • 17-23: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [20-35]

The addition of the gasPrice parameter to the serve function and its subsequent use in the NewCelestiaDA call is correctly implemented.

cmd/celestia-da/cmd.go (3)
  • 15-15: The new constant grpcGasPriceFlag is correctly defined for the CLI flag.

  • 27-27: The gasPrice flag is correctly added to the flag set with a default value of -1.

  • 46-46: The gasPrice is correctly retrieved from the command flags and passed to the serve function.

celestia_test.go (1)
  • 103-103: The NewCelestiaDA function call within the TestCelestiaDA method correctly passes -1 for the gasPrice to use the default value.
celestia/celestia_test.go (3)
  • 40-40: The NewCelestiaDA function call in the setup method is correctly updated to include the gasPrice parameter.

  • 127-133: The new test case Submit_existing_with_gasprice_global correctly sets a global gasPrice and tests the Submit method.

  • 135-135: The new test case Submit_existing_with_gasprice_override correctly tests the Submit method with an overridden gasPrice.

celestia/celestia.go (3)
  • 26-26: The gasPrice field is correctly added to the CelestiaDA struct.

  • 31-35: The NewCelestiaDA function signature is correctly updated to accept the gasPrice parameter.

  • 85-94: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [88-104]

The Submit method is correctly updated to handle the gasPrice parameter and utilize the gasPrice field if configured globally.

cmd/celestia-da/server.go Show resolved Hide resolved
@tuxcanfly tuxcanfly merged commit 5bbaa8c into main Jan 11, 2024
16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature Request]: allow configuring global gas price
3 participants