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: return timestamp from GetIDs #103

Merged
merged 7 commits into from
Sep 19, 2024
Merged

feat: return timestamp from GetIDs #103

merged 7 commits into from
Sep 19, 2024

Conversation

tzdybal
Copy link
Member

@tzdybal tzdybal commented Sep 17, 2024

Overview

Enhanced the GetIDs functionality to include a timestamp in the response, both in the proto files and Go structures. Updated relevant files and added checks for the new field in the tests.

Resolves #101

Summary by CodeRabbit

  • New Features

    • Introduced a new GetIDsResult structure that includes both IDs and a timestamp, enhancing the context of retrieved data.
    • Added a timestamp field to the GetIdsResponse message for improved temporal context.
    • Implemented a new check-proto-deps target to streamline protobuf dependency management.
    • Updated plugin configuration to utilize gocosmos for better compatibility with the Cosmos ecosystem.
    • Added a new dependency on buf.build/cosmos/gogo-proto to enhance protobuf processing.
  • Bug Fixes

    • Updated methods to ensure they return the new structured response, improving data handling and validation.
  • Chores

    • Enhanced GitHub Actions workflows to set up the Go environment for executing commands.
    • Removed outdated scripts for protobuf generation, transitioning to a more efficient method.

Copy link

coderabbitai bot commented Sep 17, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the Makefile, updating Protocol Buffers configurations, and modifying the GetIDs method to return a new structure, GetIDsResult, which includes both a list of IDs and a timestamp. These adjustments ensure better management of protobuf file generation and linting processes while providing additional context regarding when the IDs were retrieved across various components.

Changes

Files Change Summary
proxy/grpc/client.go, proxy/grpc/server.go Modified the GetIDs method to return a pointer to GetIDsResult instead of a slice of ID, which now includes a timestamp. Updated the server method to handle the new return structure, including the timestamp in the response.
proto/da/da.proto Added a new google.protobuf.Timestamp timestamp field to the GetIdsResponse message to provide temporal context for the retrieved IDs.
Makefile, buf.gen.yaml, buf.yaml, go.mod Enhanced protobuf file generation and linting processes, including the addition of a check-proto-deps target and updates to plugin configurations.
test/test_suite.go Adjusted test functions to validate the new return structure, ensuring that the timestamp is checked alongside the IDs.

Assessment against linked issues

Objective Addressed Explanation
GetIDs method should return list of IDs and timestamp (#[101])

Possibly related PRs

  • proto: rename GetIDs to GetIds #51: The changes in the main PR involve modifications to protobuf file handling, while this PR focuses on renaming methods related to protobuf definitions, indicating a connection in the context of protobuf usage.

Suggested reviewers

  • tuxcanfly
  • nashqueue
  • tzdybal
  • gupadhyaya

Poem

🐇 In the land of code, where rabbits play,
A new GetIDs shines bright today!
With timestamps added, oh what a treat,
Fetching IDs just got more neat!
Hopping through changes, we cheer with delight,
For clearer returns, our future is bright! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5dddcb5 and f132b11.

Files selected for processing (2)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/proto.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/lint.yml
Additional context used
Learnings (1)
.github/workflows/proto.yml (1)
Learnt from: MSevey
PR: rollkit/go-da#103
File: .github/workflows/proto.yml:11-11
Timestamp: 2024-09-18T17:58:49.488Z
Learning: In GitHub Actions workflows for Go projects, include the `setup-go` action to ensure the Go environment is properly set up.
Additional comments not posted (1)
.github/workflows/proto.yml (1)

12-15: LGTM! The addition of the setup-go step is a great improvement.

The inclusion of the setup-go action ensures that the correct Go environment is set up before running the build commands. This change aligns with the learning and addresses the issue mentioned in the past review comment.

Using the go-version-file parameter to read the Go version from the go.mod file is a convenient way to ensure the workflow uses the same version as the project.


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 generate interesting stats about this repository and render them as a table.
    -- @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.

CodeRabbit Configuration 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.

@RollkitBot RollkitBot requested review from a team, tuxcanfly, gupadhyaya and Manav-Aggarwal and removed request for a team September 17, 2024 13:35
@tzdybal tzdybal added enhancement New feature or request T:enhancement and removed enhancement New feature or request labels Sep 17, 2024
proxy/jsonrpc/client.go Outdated Show resolved Hide resolved
@gupadhyaya
Copy link
Member

could you fix golangci-lint? otherwise, LGTM

proto/da/da.proto Outdated Show resolved Hide resolved
Enhanced the GetIDs functionality to include a timestamp in the response, both in the proto files and Go structures. Updated relevant files and added checks for the new field in the tests.
@tzdybal tzdybal force-pushed the tzdybal/timestamp branch 7 times, most recently from 0ae50c1 to db276af Compare September 18, 2024 15:15
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
proxy/grpc/client.go (1)

69-80: Approve the changes to the GetIDs method.

The changes to the GetIDs method look good:

  • The return type has been updated to *da.GetIDsResult to include the timestamp along with the IDs, aligning with the PR objective.
  • The timestamp is correctly extracted from the response using types.TimestampFromProto.
  • The new da.GetIDsResult struct is a good choice for returning the IDs and timestamp, as it makes the return values more explicit.
  • Error handling for the timestamp conversion is properly implemented.

Note that this is a breaking change due to the modified method signature. Ensure that all callers of this method are updated to handle the new return type.

The addition of the timestamp provides valuable context to the caller about when the IDs were retrieved. This extra information can be beneficial for debugging, logging, and understanding the state of the system at a given point in time.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 456872e and db276af.

Files ignored due to path filters (3)
  • buf.lock is excluded by !**/*.lock
  • go.sum is excluded by !**/*.sum
  • types/pb/da/da.pb.go is excluded by !**/*.pb.go
Files selected for processing (13)
  • Makefile (1 hunks)
  • buf.gen.yaml (1 hunks)
  • buf.yaml (1 hunks)
  • da.go (3 hunks)
  • go.mod (3 hunks)
  • proto/da/da.proto (2 hunks)
  • proto/gen.sh (0 hunks)
  • proto/protoc.sh (0 hunks)
  • proxy/grpc/client.go (2 hunks)
  • proxy/grpc/server.go (2 hunks)
  • proxy/jsonrpc/client.go (2 hunks)
  • test/dummy.go (6 hunks)
  • test/test_suite.go (2 hunks)
Files not reviewed due to no reviewable changes (2)
  • proto/gen.sh
  • proto/protoc.sh
Files skipped from review as they are similar to previous changes (5)
  • da.go
  • proto/da/da.proto
  • proxy/jsonrpc/client.go
  • test/dummy.go
  • test/test_suite.go
Additional comments not posted (12)
buf.yaml (2)

2-3: LGTM!

The addition of the buf.build/cosmos/gogo-proto dependency is a common practice in projects that utilize Protobuf and require Golang-specific features. It is a well-known and widely-used package in the Cosmos ecosystem.


10-10: LGTM!

The change from DEFAULT to STANDARD linting rule is a good practice to enforce stricter coding standards and improve code quality. It demonstrates the project's commitment to maintaining a clean and consistent codebase.

buf.gen.yaml (1)

6-15: LGTM! The changes enhance the code generation process.

The shift to the gocosmos plugin and the expanded type mappings offer several potential benefits:

  • Improved integration with the Cosmos ecosystem.
  • Better type handling in the generated code.
  • More granular control over the code generation process.

The retention of gRPC-related settings ensures that the core functionality remains intact.

Overall, these changes reflect a significant update in the code generation process while maintaining compatibility and potentially improving the generated code quality.

go.mod (3)

6-6: LGTM!

The addition of github.com/cosmos/gogoproto at version v1.7.0 aligns with the PR objectives and ensures a stable version of the library is used.


16-16: LGTM!

The addition of github.com/google/go-cmp at version v0.6.0 as an indirect dependency is acceptable. It ensures a stable version of the library is used by the module's dependencies.


30-30: LGTM!

The update of google.golang.org/protobuf to version v1.34.2 is a minor version bump that should include bug fixes and improvements while maintaining backward compatibility.

Makefile (3)

68-74: LGTM!

The new check-proto-deps target is a good addition to ensure that the necessary protobuf dependency is installed before running the proto-gen and proto-lint targets. This improves the reliability of the build process.


76-80: LGTM!

The modifications to the proto-gen target improve the robustness of the protobuf file generation process. Using the buf tool provides a more standardized and maintainable approach compared to custom scripts. The dependency on check-proto-deps ensures that the necessary protobuf dependency is installed before running the target.


83-87: LGTM!

The modifications to the proto-lint target improve the robustness of the protobuf file linting process. Using the buf tool provides a more standardized and maintainable approach compared to custom scripts. The dependency on check-proto-deps ensures that the necessary protobuf dependency is installed before running the target.

proxy/grpc/server.go (2)

6-6: LGTM!

The import statement is valid and does not raise any concerns. The package is likely used in the subsequent code changes.


42-51: Excellent work!

The code segment correctly implements the required changes to include the timestamp in the GetIds response. It appropriately captures the response from p.target.GetIDs, converts the timestamp using types.TimestampProto, handles the potential error, and returns a pbda.GetIdsResponse with the converted timestamp and IDs. The changes align with the method signature and the expected behavior.

proxy/grpc/client.go (1)

6-6: LGTM!

The import statement for the github.com/cosmos/gogoproto/types package has been added correctly. This package is commonly used when working with protocol buffer types in Go.

@tzdybal tzdybal force-pushed the tzdybal/timestamp branch 3 times, most recently from ad36445 to f32a51d Compare September 18, 2024 15:27
Removed old protobuf generation shell scripts and updated Makefile to use Buf. Changed dependencies and updated configurations accordingly. This modernizes the setup and removes the dependency on Docker.
Replaced the int64 timestamp with google.protobuf.Timestamp in the GetIdsResponse message. Adjusted the generated code to handle the new timestamp type and updated the protobuf imports accordingly.
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.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between db276af and c82ed55.

Files ignored due to path filters (3)
  • buf.lock is excluded by !**/*.lock
  • go.sum is excluded by !**/*.sum
  • types/pb/da/da.pb.go is excluded by !**/*.pb.go
Files selected for processing (11)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/proto.yml (1 hunks)
  • Makefile (1 hunks)
  • buf.gen.yaml (1 hunks)
  • buf.yaml (1 hunks)
  • go.mod (3 hunks)
  • proto/da/da.proto (2 hunks)
  • proto/gen.sh (0 hunks)
  • proto/protoc.sh (0 hunks)
  • proxy/grpc/client.go (2 hunks)
  • proxy/grpc/server.go (2 hunks)
Files not reviewed due to no reviewable changes (2)
  • proto/gen.sh
  • proto/protoc.sh
Files skipped from review as they are similar to previous changes (5)
  • buf.gen.yaml
  • buf.yaml
  • go.mod
  • proto/da/da.proto
  • proxy/grpc/server.go
Additional context used
actionlint
.github/workflows/proto.yml

11-11: shellcheck reported issue in this script: SC2086:info:1:36: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/lint.yml

55-55: shellcheck reported issue in this script: SC2086:info:1:36: Double quote to prevent globbing and word splitting

(shellcheck)

Additional comments not posted (6)
Makefile (3)

68-73: LGTM!

The addition of the check-proto-deps target is a good practice to ensure that the necessary dependencies are present before running the proto-gen and proto-lint targets. This helps maintain a reliable build environment.


75-78: LGTM!

The modifications to the proto-gen target are beneficial:

  • Depending on the check-proto-deps target ensures that the necessary dependencies are present before generating the protobuf files.
  • Updating the command to use the buf tool enhances the efficiency and reliability of the protobuf file generation process.

81-84: LGTM!

The modifications to the proto-lint target are beneficial:

  • Depending on the check-proto-deps target ensures that the necessary dependencies are present before linting the protobuf files.
  • Updating the command to use the buf tool enhances the efficiency and reliability of the protobuf file linting process.
proxy/grpc/client.go (3)

6-6: LGTM!

The import statement for the types package from github.com/cosmos/gogoproto is necessary to support the changes made in the GetIDs method for working with protocol buffer timestamp types.


Line range hint 1-68: Skipped reviewing unchanged code.

The remaining code in the file is unchanged and does not require further review.

Also applies to: 81-165


69-80: Excellent work on enhancing the GetIDs method!

The changes made to the GetIDs method align perfectly with the PR objective to return a timestamp along with the IDs. Key highlights:

  • The method signature has been appropriately modified to return a pointer to da.GetIDsResult, which is a struct containing the IDs and the timestamp.
  • The timestamp is correctly extracted from the response using types.TimestampFromProto and any error during the conversion is properly handled.
  • Returning a struct instead of a tuple enhances the readability and maintainability of the code.

Please ensure that all callers of the GetIDs method are updated to handle the new return type. You can use the following script to find the callers:

Verification successful

GetIDs method changes have been consistently implemented

The modifications to the GetIDs method have been successfully and consistently implemented across the codebase. Key observations:

  • The method signature returning (*da.GetIDsResult, error) is uniform across all implementations (da.go, test/dummy.go, proxy/jsonrpc/client.go, proxy/grpc/client.go).
  • Test cases in test/test_suite.go have been updated to use the new signature.
  • The gRPC server (proxy/grpc/server.go) and JSON-RPC client (proxy/jsonrpc/client.go) are correctly using the new GetIDs method signature.

These findings confirm that the changes have been properly propagated throughout the codebase, and all callers have been updated to handle the new return type (struct containing IDs and timestamp).

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all callers of the `GetIDs` method.

# Test: Search for the method usage. Expect: List of files containing the method calls.
rg --type go -w $'\\.\\.GetIDs\\('

Length of output: 32


Script:

#!/bin/bash
# Description: Find potential callers of the GetIDs method and verify its definition

# Search for potential GetIDs method calls with a more lenient pattern
echo "Searching for potential GetIDs method calls:"
rg --type go 'GetIDs\('

# Search for the GetIDs method definition
echo -e "\nSearching for GetIDs method definition:"
rg --type go 'func.*GetIDs\('

# If we still can't find anything, search for any occurrence of 'GetIDs'
echo -e "\nSearching for any occurrence of 'GetIDs':"
rg --type go 'GetIDs'

Length of output: 3346

.github/workflows/proto.yml Outdated Show resolved Hide resolved
.github/workflows/lint.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

I think the edits to the workflow files actually just need https://github.com/actions/setup-go

@tzdybal tzdybal force-pushed the tzdybal/timestamp branch 2 times, most recently from af30fa1 to e113a6a Compare September 18, 2024 19:01
Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

One more improvement we might as well make since we are touching the CI files

.github/workflows/lint.yml Outdated Show resolved Hide resolved
@tzdybal tzdybal requested a review from MSevey September 18, 2024 20:22
@MSevey MSevey added this pull request to the merge queue Sep 19, 2024
Merged via the queue into main with commit 04e312a Sep 19, 2024
14 checks passed
@MSevey MSevey deleted the tzdybal/timestamp branch September 19, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

GetIDs should return timestamp
3 participants