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(tools): block ETA #3829

Merged
merged 2 commits into from
Aug 30, 2024
Merged

feat(tools): block ETA #3829

merged 2 commits into from
Aug 30, 2024

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Aug 28, 2024

I used this tool to predict the arrival time of the v2 activation height on Mocha.

@rootulp rootulp self-assigned this Aug 28, 2024
@rootulp rootulp requested a review from a team as a code owner August 28, 2024 02:47
@rootulp rootulp requested review from cmwaters and evan-forbes and removed request for a team August 28, 2024 02:47
Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Walkthrough

Walkthrough

The changes introduce a new command-line tool called blocketa, which estimates the time of arrival for a specified block height within the Celestia blockchain network. The implementation includes a README.md file that provides usage instructions and a main.go file that manages command-line interactions, retrieves node status, and calculates estimated arrival times based on the current block height and average block time.

Changes

Files Change Summary
tools/blocketa/README.md Added a comprehensive overview of the blocketa tool's functionality, usage, and configuration notes.
tools/blocketa/main.go Introduced a command-line tool for estimating block arrival times, including input validation and output details.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant RPC
    participant Node

    User->>CLI: Execute command with RPC endpoint and block height
    CLI->>RPC: Validate inputs
    RPC->>Node: Retrieve current status
    Node-->>RPC: Return current block height and time
    RPC-->>CLI: Provide node status
    CLI->>CLI: Calculate estimated arrival time
    CLI-->>User: Display estimated arrival time and details
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7763c79 and 389d481.

Files selected for processing (1)
  • tools/blocketa/README.md (1 hunks)
Additional context used
Markdownlint
tools/blocketa/README.md

18-18: null
Bare URL used

(MD034, no-bare-urls)

Additional comments not posted (3)
tools/blocketa/README.md (3)

1-4: Clear and concise introduction.

The introduction provides a succinct description of the blocketa tool and its purpose. This sets a clear context for the user.


5-15: Detailed usage example provided.

The usage example is comprehensive, showing command execution and output which helps users understand how to use the tool effectively.


17-18: Important note on hardcoded block time.

The note about the hardcoded block time is crucial for users who might use this tool on different networks. It's good that it directs users to resources for finding the correct block time.

Tools
Markdownlint

18-18: null
Bare URL used

(MD034, no-bare-urls)


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

@celestia-bot celestia-bot requested a review from a team August 28, 2024 02:47
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: 2

Comment on lines +38 to +43
func Run() error {
if len(os.Args) < 3 {
fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Print error messages to os.Stderr.

Error messages should be printed to os.Stderr instead of os.Stdout for better error handling.

Apply this diff to print error messages to os.Stderr:

 fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
 fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
 fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
 return nil
-	fmt.Printf("ERROR: %s", err.Error())
+	fmt.Fprintf(os.Stderr, "ERROR: %s", err.Error())

Comment on lines +40 to +43
fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve the usage message.

The usage message can be improved for better readability.

Apply this diff to improve the usage message:

-	fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
-	fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
-	fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
+	fmt.Fprintf(os.Stderr, "Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
+	fmt.Fprintf(os.Stderr, "Example (Arabica): %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
+	fmt.Fprintf(os.Stderr, "Example (Mocha): %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fmt.Printf("Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
fmt.Printf("Example: %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
return nil
fmt.Fprintf(os.Stderr, "Usage: %s <node_rpc> <target_block_height>\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Example (Arabica): %s %s %v\n", os.Args[0], exampleArabicaRPC, exampleArabicaHeight)
fmt.Fprintf(os.Stderr, "Example (Mocha): %s %s %v\n", os.Args[0], exampleMochaRPC, exampleMochaHeight)
return nil

@rootulp rootulp changed the title feat(tools): blocketa feat(tools): block ETA Aug 28, 2024
evan-forbes
evan-forbes previously approved these changes Aug 29, 2024
cmwaters
cmwaters previously approved these changes Aug 30, 2024
Comment on lines 17 to 18
> [!NOTE]
> The block time is currently hard-coded. If you're running this for a network with a different block time, you'll need to update the blocktime constant in the main.go file.
Copy link
Contributor

Choose a reason for hiding this comment

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

You could mention the blocktime tool to estimate the cadence of block production

tools/blocketa/README.md Outdated Show resolved Hide resolved
@rootulp rootulp dismissed stale reviews from cmwaters and evan-forbes via 389d481 August 30, 2024 14:04
@rootulp rootulp enabled auto-merge (squash) August 30, 2024 14:04
@celestia-bot celestia-bot requested a review from a team August 30, 2024 14:05
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

Comment on lines +17 to +18
> [!NOTE]
> The block time is currently hard-coded. If you're running this for a network with a different block time, you'll need to update the `blockTime` constant in the main.go file. You can use https://www.mintscan.io/celestia/block/ or the blocktime tool.
Copy link
Contributor

Choose a reason for hiding this comment

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

Address the bare URL issue.

The Markdownlint tool flagged the use of a bare URL. It's best practice to use descriptive text for URLs to improve readability and accessibility.

Consider updating the URL to use descriptive text. For example:

- You can use the [Mintscan Celestia Block Explorer](https://www.mintscan.io/celestia/block/) or the blocktime tool.
Tools
Markdownlint

18-18: null
Bare URL used

(MD034, no-bare-urls)

@rootulp rootulp merged commit 43344db into celestiaorg:main Aug 30, 2024
32 checks passed
@rootulp rootulp deleted the rp/blocketa branch August 31, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants