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

build(deps)!: update prost, tokio, tonic and other dependencies #95

Merged
merged 13 commits into from
Oct 7, 2024

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Aug 23, 2024

Issue being fixed or feature implemented

New version of libraries like prost, tokio and tonic were released.

What was done?

  1. Updated dependencies
  2. Moved version in Cargo.toml from crate-level to package-level
  3. Adjusted code for new prost version
  4. Updated Alpine in tests to 3.19, as currently used 3.17 will EOL soon
  5. Updated Debian in tests to bookworm.

How Has This Been Tested?

run tests locally

Breaking Changes

Related projects must use matching versions of prost, tokio and tonic.

Rust 1.80 is required.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Enhanced Dockerfiles with updated base images for better compatibility.
    • Introduced verbose mode in the release script for clearer output during execution.
  • Bug Fixes

    • Improved error handling in the release script to provide user-friendly messages.
  • Dependency Updates

    • Updated several dependencies across multiple packages for improved performance and compatibility, including bollard, tokio, prost, and tonic.
  • Documentation

    • Streamlined test assertions for clarity in unit tests.
  • Refactor

    • Consolidated import paths for better organization and maintainability in codebase.
    • Updated the Signable trait to unify naming conventions across implementations.

@lklimek lklimek added this to the 1.2 milestone Aug 23, 2024
@lklimek lklimek changed the title build(deps)!: update prost, tokio, tonic build(deps)!: update prost, tokio, tonic and other dependencies Aug 23, 2024
@lklimek lklimek changed the base branch from master to develop August 30, 2024 13:41
Cargo.toml Outdated

[workspace.package]

rust-version = "1.76"
Copy link
Member

Choose a reason for hiding this comment

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

1.80?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is "minimal" version supported by the crate, and it supports 1.76.

Bumping this will be a breaking change.

But I have changed the Dockerfiles to ensure everything builds on 1.76.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I found out that it doesn't build cleanly on 1.76, updating to 1.80 as you suggested.

@lklimek lklimek requested a review from shumkov September 5, 2024 08:06
@lklimek lklimek self-assigned this Sep 5, 2024
Copy link
Member

@shumkov shumkov left a comment

Choose a reason for hiding this comment

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

👍

@lklimek lklimek modified the milestones: 1.2, 1.3 Sep 19, 2024
Copy link
Contributor

coderabbitai bot commented Oct 5, 2024

Walkthrough

The pull request introduces several updates across various Cargo.toml files, Dockerfiles, and Rust source files. Key changes include the addition of workspace configurations, updates to dependency versions, and modifications to import paths. The Dockerfiles have been updated to use new base images, enhancing build processes and error handling. Additionally, several Rust files have been modified to improve organization and functionality, including deprecating certain methods and refining test cases. Overall, the changes reflect a comprehensive update to the project's dependencies and build configurations.

Changes

File Change Summary
Cargo.toml Added [workspace.package] section with rust-version and version; updated various dependency versions.
Dockerfile-alpine Updated base image to rust:1.80-alpine3.20; modified SHELL command; adjusted protoc installation.
Dockerfile-debian Updated base image to rust:1.80.0-bookworm; modified SHELL command; improved package installation logic.
abci/Cargo.toml Updated package version and dependencies; added workspace settings.
abci/src/lib.rs Updated import paths for DecodeError and EncodeError.
abci/src/server/codec.rs Changed imports for encoding/decoding functions; updated decode and encode methods.
abci/src/signatures.rs Deprecated sign_digest; introduced calculate_sign_hash method.
abci/tests/grpc.rs Updated import paths for tonic to tenderdash_proto::tonic.
proto-compiler/Cargo.toml Updated package version and dependencies; added workspace settings.
proto/Cargo.toml Updated package version and dependencies; added workspace settings.
proto/src/lib.rs Re-exported prost crate for enhanced visibility.
proto/src/protobuf.rs Modified Timestamp and Duration structs to derive Clone + Copy.
proto/tests/unit.rs Adjusted tests for ResponseException; confirmed BlockId struct implementation remains unchanged.
scripts/release.sh Enhanced error handling; added verbose mode; simplified file path updates.

Poem

🐇 In the land of code where rabbits play,
New versions hop in, brightening the day.
Dependencies dance, and imports align,
With each little change, our project will shine!
So let's celebrate with a joyful cheer,
For every small update brings progress near! 🌟


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

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

🧹 Outside diff range and nitpick comments (7)
Dockerfile-debian (2)

4-4: LGTM! Consider using a more flexible version constraint.

The update to rust:1.80.0-bookworm aligns with the new Rust version requirement mentioned in the PR objectives. This ensures compatibility with the updated dependencies.

Consider using a more flexible version constraint like rust:1.80-bookworm to automatically get minor updates and security patches while still maintaining the major version requirement.


Line range hint 38-47: Great optimizations for the build process!

The updates to the cargo build command introduce several improvements:

  1. Caching mechanisms for Cargo's registry and git database, which will speed up subsequent builds.
  2. The --config net.git-fetch-with-cli=true option addresses an ARM build issue.
  3. The cargo clean command at the end helps preserve space on GitHub cache.

These changes will significantly improve build performance and efficiency.

Consider adding a comment explaining the purpose of the cargo clean command, as its placement at the end of the build process might not be immediately obvious to all readers.

Dockerfile-alpine (2)

3-3: Approved: Base image update looks good.

The update to rust:1.80-alpine3.20 aligns with the PR objectives and provides a more recent Alpine version, which is good for security and compatibility.

Consider using a more specific Rust version (e.g., rust:1.80.0-alpine3.20) to ensure reproducible builds across different environments.


Line range hint 18-26: Approved: Improved protoc installation process.

The updated protoc installation process correctly handles different architectures (ARM64 and x86_64) using the BUILDPLATFORM. This change enhances the Dockerfile's compatibility across different build environments.

Consider adding a comment explaining the purpose of the conditional PROTOC_ARCH setting for better readability. For example:

# Set PROTOC_ARCH based on build platform to ensure correct protoc version is downloaded
RUN if [[ "$BUILDPLATFORM" == "linux/arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64 ; fi; \
    # ... rest of the command
scripts/release.sh (1)

95-97: Improved error handling and version updating process. Consider minor enhancements.

The changes improve the script's robustness and maintainability:

  1. Adding set -ex enhances error handling and debugging.
  2. Simplifying the sed command for Cargo.toml makes it more maintainable.
  3. Updating DEFAULT_VERSION in build.rs ensures consistency.
  4. Using cargo fmt maintains code style consistency.

Consider the following minor improvements:

  1. Check if files exist before modifying them to prevent potential errors:
if [ -f "./Cargo.toml" ]; then
    sed -i "s/^version = .*/version = \"$rs_tenderdash_abci_version\"/" ./Cargo.toml
else
    echo "Error: Cargo.toml not found"
    exit 1
fi

if [ -f "./proto/build.rs" ]; then
    sed -i "s/^\s*const DEFAULT_VERSION: &str = \".*\";/const DEFAULT_VERSION: \&str = \"v$td_version\";/" ./proto/build.rs
    cargo fmt -- ./proto/build.rs
else
    echo "Error: proto/build.rs not found"
    exit 1
fi
  1. Consider not suppressing stderr for cargo fmt to catch potential warnings:
cargo fmt -- ./proto/build.rs

These changes will make the script more robust and help catch potential issues earlier.

proto/src/lib.rs (1)

34-34: Approved: Exposing prost crate improves usability but increases API surface.

The addition of pub use prost; makes the prost crate publicly available to users of this library. This change aligns with the library's purpose and may simplify usage for consumers who need direct access to prost functionality.

However, be aware that this increases the API surface and creates a tighter coupling with the prost crate, which could impact future maintenance and make it harder to change the underlying Protobuf implementation if needed.

Consider documenting this change and its implications in the library's documentation to inform users about the availability of prost and any potential impact on semantic versioning.

abci/src/server/codec.rs (1)

Line range hint 168-172: LGTM! Consider enhancing error handling.

The updated decode method correctly uses the newly imported decode_varint function. The error handling improvement helps distinguish between partial length delimiters and actual errors, which is a good practice.

Consider adding a more specific error type for the case when the source buffer exceeds MAX_VARINT_LENGTH but still fails to decode. This could help in debugging potential issues:

Err(e) => {
    if src_len > MAX_VARINT_LENGTH {
        return Err(Error::InvalidVarint(src_len));
    }
    return Err(e.into());
},

This assumes you have an InvalidVarint variant in your Error enum. If not, you might want to add one.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 79b1bcc and 3d2d494.

📒 Files selected for processing (14)
  • Cargo.toml (1 hunks)
  • Dockerfile-alpine (2 hunks)
  • Dockerfile-debian (1 hunks)
  • abci/Cargo.toml (2 hunks)
  • abci/src/lib.rs (1 hunks)
  • abci/src/server/codec.rs (3 hunks)
  • abci/src/signatures.rs (1 hunks)
  • abci/tests/grpc.rs (3 hunks)
  • proto-compiler/Cargo.toml (1 hunks)
  • proto/Cargo.toml (2 hunks)
  • proto/src/lib.rs (1 hunks)
  • proto/src/protobuf.rs (2 hunks)
  • proto/tests/unit.rs (1 hunks)
  • scripts/release.sh (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Cargo.toml
🔇 Additional comments (32)
proto-compiler/Cargo.toml (4)

9-10: LGTM: Workspace configurations added

The addition of workspace configurations for rust-version and version is a good practice. This change will help maintain consistency across multiple packages in the workspace and aligns with the PR objectives.


18-18: Verify regex downgrade, other updates look good

The updates to ureq (2.9.6 to 2.10) and zip (2.1.3 to 2.2) are minor and align with the PR objectives. However, the downgrade of regex from 1.10.4 to 1.10 is unusual.

Could you please provide the rationale for downgrading the regex crate? It's important to ensure this doesn't introduce any compatibility issues or remove any needed functionality.

To verify the impact of these changes, especially the regex downgrade, please run the following script:

#!/bin/bash
# Description: Check for any issues related to the dependency updates

# Test: Check for any usage of regex features that might have been removed
rg --type rust 'regex::' -C 3

# Test: Run tests to ensure functionality is not broken
cargo test

# Test: Check for any warnings related to the updated dependencies
cargo build 2>&1 | grep -E "warning:.*regex|warning:.*ureq|warning:.*zip"

Also applies to: 20-21


23-23: tonic-build update looks good, verify compatibility

The update of tonic-build from 0.11.0 to 0.12 aligns with the PR objectives. While this is a minor version update, it could potentially introduce breaking changes. Since it's an optional dependency, it's crucial to ensure that this update doesn't cause any compatibility issues when the grpc feature is enabled.

To verify compatibility, please run the following script:


16-17: Dependency updates look good, verify compatibility

The updates to prost-build (0.12.4 to 0.13) and tempfile (3.10.1 to 3.12) align with the PR objectives. These are minor version updates and should not introduce breaking changes. However, it's important to ensure that these updates don't cause any compatibility issues with the rest of the codebase.

To verify compatibility, please run the following script:

Dockerfile-debian (2)

6-6: Excellent improvement to shell execution!

The update to SHELL ["/bin/bash", "-exc"] enhances the build process in two ways:

  1. The -e flag ensures the build fails fast if any command encounters an error.
  2. The -x flag enables command tracing, which aids in debugging by showing each command as it's executed.

These changes will make the build process more robust and easier to troubleshoot.


Line range hint 1-47: Overall, excellent updates to the Dockerfile!

The changes in this Dockerfile align well with the PR objectives and introduce several improvements:

  1. Updated base image to a specific Rust version, ensuring compatibility with new dependency requirements.
  2. Enhanced shell configuration for better error handling and debugging.
  3. Optimized build process with caching mechanisms and ARM-specific configurations.

These updates will result in a more robust, efficient, and maintainable build process. Great job on these improvements!

Dockerfile-alpine (2)

15-15: Approved: Enhanced shell configuration improves build process.

The updated SHELL command with -exc flags improves the build process in two ways:

  1. The -e flag ensures the build fails immediately if any command exits with an error, preventing silent failures.
  2. The -x flag prints each command before execution, which aids in debugging if issues occur.

Line range hint 1-55: Overall: Excellent improvements to the Dockerfile.

The changes made to this Dockerfile significantly enhance its functionality and robustness:

  1. The base image update ensures compatibility with Rust 1.80 and provides a more recent Alpine version.
  2. The improved shell configuration with -exc flags enhances error handling and debugging during the build process.
  3. The updated protoc installation process now supports both ARM64 and x86_64 architectures, improving cross-platform compatibility.

These improvements align well with the PR objectives and contribute to a more maintainable and reliable build process.

proto/Cargo.toml (6)

22-23: LGTM: Workspace configurations added

The addition of workspace configurations for rust-version and version promotes consistency across the project. This is a good practice for maintaining uniformity in a multi-package workspace.


54-55: LGTM: Minor dependency updates

The updates to bytes, serde, num-traits, and chrono are minor version increments. These updates likely include bug fixes and performance improvements without introducing breaking changes.

Also applies to: 61-61, 68-68


Line range hint 22-73: Summary of Cargo.toml changes

The updates in this file align with the PR objectives, introducing new versions of prost, tonic, and other dependencies. These changes bring potential improvements but also introduce breaking changes that require careful attention.

Key points:

  1. Workspace configurations have been added for consistency.
  2. Major version updates to prost (0.13) and tonic (0.12) may introduce breaking changes.
  3. Other dependencies have been updated to their latest minor versions.
  4. derive_more has been updated to 1.0 with new features added.

Please ensure that:

  1. The codebase is compatible with all updated dependencies, especially prost and tonic.
  2. The project now requires Rust 1.80 as mentioned in the PR objectives.
  3. All breaking changes are addressed and the codebase is adjusted accordingly.
  4. New features from derive_more are utilized where appropriate.

These changes will likely improve the project's performance and maintainability, but thorough testing is crucial to ensure everything works as expected with the updated dependencies.


53-53: Verify compatibility with tonic 0.12

The update to tonic 0.12 aligns with the PR objectives. As this is a major version update, it may introduce breaking changes.

Please ensure that:

  1. The codebase is compatible with the new tonic version.
  2. Any breaking changes are addressed.

Run the following script to check for any usage of deprecated or removed tonic features:

#!/bin/bash
# Description: Check for potential breaking changes in tonic usage

# Search for tonic usage in the codebase
rg --type rust 'use tonic|tonic::'

69-69: Verify compatibility with derive_more 1.0 and new features

The update to derive_more 1.0 with additional features is a significant change. While version 1.0 often indicates API stability, it's important to verify compatibility.

Please ensure that:

  1. The codebase is compatible with derive_more 1.0.
  2. The new features "from" and "from_str" are properly utilized where needed.

Run the following script to check for derive_more usage and potential areas where the new features could be applied:

#!/bin/bash
# Description: Check derive_more usage and potential areas for new features

# Search for derive_more usage
rg --type rust 'use derive_more|#\[derive\('

# Search for potential areas to use new "from" and "from_str" features
rg --type rust 'impl From<.*> for' -g '!**/target/**'
rg --type rust 'impl FromStr for' -g '!**/target/**'

50-52: Verify compatibility with prost 0.13

The update to prost 0.13 is in line with the PR objectives. However, as this is a major version update, it may introduce breaking changes.

Please ensure that:

  1. The codebase is compatible with the new prost version.
  2. Any breaking changes are addressed.
  3. The project now requires Rust 1.80 as mentioned in the PR objectives.

Run the following script to check for any usage of deprecated or removed prost features:

abci/Cargo.toml (4)

Line range hint 1-85: Summary of Cargo.toml changes

The changes in this file align with the PR objectives of updating dependencies. Key points:

  1. Workspace configuration has been added, which may impact version management across the project.
  2. Dependencies have been updated (bollard, tokio) and removed (prost), which may require compatibility checks.
  3. The tonic dev-dependency has been commented out, potentially affecting gRPC-related tests.

Please ensure all suggested verifications are performed to maintain the project's stability and test coverage.


82-85: Verify impact of removing tonic from dev-dependencies.

The tonic dependency has been commented out in the dev-dependencies section. This suggests that gRPC server tests may no longer be included or have been moved elsewhere.

Please clarify the reason for removing the tonic dependency and confirm that this doesn't negatively impact the project's test coverage. Run the following script to check for any remaining tonic usage:

#!/bin/bash
# Description: Check for any remaining tonic usage in tests

# Test 1: Search for tonic usage in test files
rg "use.*tonic" --type rust --glob "**/*test*.rs"

# Test 2: Check if there are any gRPC-related tests that might be affected
rg "gRPC|grpc" --type rust --glob "**/*test*.rs"

If tonic is still being used or if there are gRPC-related tests, please ensure they are properly addressed or explain why they are no longer needed.


80-80: Dependency versions updated: Verify compatibility and test coverage.

The following changes have been made to the dependencies:

  • bollard updated from "0.16.1" to "0.17"
  • tokio updated from "1.37.0" to "1.39"
  • prost dependency has been removed

These updates align with the PR objectives and are generally good for security and feature improvements.

To ensure these changes don't introduce any compatibility issues, please run the following script:

#!/bin/bash
# Description: Verify updated dependencies and their impact

# Test 1: Check for any breaking changes in bollard 0.17
rg -i "breaking.?changes" $(fd -t f -e md | grep -i "bollard.*changelog")

# Test 2: Check for any breaking changes in tokio 1.39
rg -i "breaking.?changes" $(fd -t f -e md | grep -i "tokio.*changelog")

# Test 3: Verify that prost is not used anywhere in the codebase
if rg "use.*prost" --type rust; then
    echo "Warning: prost is still being used in the codebase despite being removed from dependencies."
fi

# Test 4: Run the test suite to ensure everything still works
cargo test --all-features

Additionally, please ensure that the test coverage is adequate for the updated dependencies, especially for any new features or changed APIs.

Also applies to: 82-82


15-16: Workspace configuration added: Verify project-wide impact.

The addition of rust-version.workspace = true and version.workspace = true indicates that this package is now part of a workspace configuration. This change can help maintain consistency across multiple packages in the project.

To ensure this change doesn't unexpectedly affect other parts of the project, please run the following script:

✅ Verification successful

Workspace configuration verified successfully.

The workspace is correctly configured with the [workspace] section, defined members, and consistent versioning across all packages. No issues were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify workspace configuration and its impact on other packages

# Test 1: Check if a workspace root Cargo.toml exists
if [ -f "./Cargo.toml" ]; then
    echo "Workspace root Cargo.toml found."
    # Check if it defines workspace members and package version
    grep -q '\[workspace\]' ./Cargo.toml && grep -q 'members' ./Cargo.toml && grep -q 'package.version' ./Cargo.toml
    if [ $? -eq 0 ]; then
        echo "Workspace configuration seems correct."
    else
        echo "Warning: Workspace configuration may be incomplete."
    fi
else
    echo "Warning: No workspace root Cargo.toml found."
fi

# Test 2: Check for other packages that might be affected
echo "Packages that might be affected by the workspace configuration:"
fd -t f -e toml | xargs grep -l 'version.workspace = true'

Length of output: 574


Script:

#!/bin/bash
# Description: Verify workspace configuration and its impact on other packages

# Test 1: Check if a workspace root Cargo.toml exists and is correctly configured
if [ -f "./Cargo.toml" ]; then
    echo "Workspace root Cargo.toml found."
    # Check if it defines [workspace], members, and package.version
    if grep -q '\[workspace\]' ./Cargo.toml; then
        echo "[workspace] section found."
    else
        echo "Warning: [workspace] section missing in Cargo.toml."
    fi

    if grep -q 'members\s*=' ./Cargo.toml; then
        echo "Workspace members are defined."
    else
        echo "Warning: Workspace members not defined."
    fi

    if grep -q 'version\s*=' ./Cargo.toml; then
        echo "Package version is set at workspace level."
    else
        echo "Warning: Package version not set at workspace level."
    fi
else
    echo "Warning: No workspace root Cargo.toml found."
fi

# Test 2: Identify other Cargo.toml files that might be affected by workspace configuration
echo "Checking other Cargo.toml files for workspace version settings..."
fd -t f -e toml | while read -r file; do
    if grep -q 'version.workspace\s*=\s*true' "$file"; then
        echo "Affected package found: $file"
    fi
done

Length of output: 1199


Script:

#!/bin/bash
# Description: Verify workspace members and consistent versioning across the workspace

# Test 1: List all workspace members
echo "Listing all workspace members defined in the root Cargo.toml:"
grep -A 100 '\[workspace\]' Cargo.toml | grep 'members' -A 100 | grep -o '".*"' | tr -d '"' || echo "No members found."

# Test 2: Verify each member's Cargo.toml for consistent versioning
echo "Verifying consistent versioning across workspace members:"
fd -t f -e toml | while read -r file; do
    if grep -q 'version.workspace\s*=\s*true' "$file"; then
        echo "$file has workspace versioning enabled."
        version=$(grep '^version\s*=' "$file" | awk -F'=' '{print $2}' | tr -d ' "')
        echo " - Version: $version"
    fi
done

# Test 3: Check for duplicate or conflicting version declarations
echo "Checking for duplicate or conflicting version declarations:"
fd -t f -e toml | grep 'version\s*=' | sort | uniq -c | sort -nr || echo "No duplicate or conflicting versions found."

Length of output: 1739

proto/src/protobuf.rs (3)

24-24: Approved: Beneficial addition of the Copy trait

The addition of the Copy trait to the Timestamp struct is a positive change. This allows for more efficient copying of Timestamp instances, which can lead to performance improvements in scenarios where these objects are frequently copied. The change is safe because the struct only contains primitive types (i64 and i32) which already implement Copy.

This modification aligns well with the PR objectives of updating and improving the codebase.


24-24: Summary: Beneficial improvements to Timestamp and Duration structs

The changes made to this file are minimal but impactful:

  1. Both Timestamp and Duration structs now implement the Copy trait.
  2. This allows for more efficient copying of these types, potentially improving performance in scenarios where they are frequently copied.
  3. The changes are safe and don't introduce any breaking changes or potential issues.

These modifications align well with the PR objectives of updating and improving the codebase. They enhance the usability and efficiency of these core types without altering their fundamental behavior.

Also applies to: 49-49


49-49: Approved: Beneficial addition of the Copy trait

The addition of the Copy trait to the Duration struct is a positive change. This allows for more efficient copying of Duration instances, which can lead to performance improvements in scenarios where these objects are frequently copied. The change is safe because the struct only contains primitive types (i64 and i32) which already implement Copy.

This modification aligns well with the PR objectives of updating and improving the codebase.

Note: The Duration struct doesn't derive ::serde::Deserialize, ::serde::Serialize like Timestamp does. This is correct because custom implementations for these traits are provided later in the file.

Let's verify the custom serialization implementations:

✅ Verification successful

Verified: Custom serialization implementations confirmed

The custom implementations of serde::Serialize and serde::Deserialize for the Duration struct have been successfully verified. This ensures that the omission of these traits in the derive attributes is properly handled by the custom implementations.

The addition of the Copy trait remains beneficial for performance and is safe given that Duration consists of primitive types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify custom serialization implementations for Duration struct

# Test: Check for custom Serialize implementation
rg --type rust "impl serde::Serialize for Duration" proto/src/protobuf.rs

# Test: Check for custom Deserialize implementation
rg --type rust "impl<'de> serde::Deserialize<'de> for Duration" proto/src/protobuf.rs

Length of output: 255

abci/tests/grpc.rs (5)

21-21: LGTM: Import path updated correctly

The import statement has been updated to use tenderdash_proto::tonic instead of tonic directly. This change is consistent with the overall refactoring to use the custom tenderdash_proto module.


61-61: LGTM: Server import updated correctly

The import for Server has been updated to use tenderdash_proto::tonic::transport::Server, which is consistent with the new import structure. This change correctly shifts the server implementation to the tenderdash_proto namespace.


128-129: LGTM: Method signature updated correctly

The echo method signature has been properly updated to use tenderdash_proto::tonic::Request and tenderdash_proto::tonic::Response. These changes align with the new import structure and ensure consistency throughout the codebase.


137-141: LGTM: Method signature and return type updated correctly

The info method signature and return type have been properly updated to use tenderdash_proto::tonic::Request, tenderdash_proto::tonic::Response, and tenderdash_proto::tonic::Status. These changes maintain consistency with the new import structure and ensure proper type usage throughout the implementation.


Line range hint 1-150: Summary: Import paths and type usage updated consistently

The changes in this file consistently update the import paths and type usage for the tonic crate to use the tenderdash_proto::tonic module. This refactoring appears to be part of a larger effort to use a custom tenderdash_proto module throughout the codebase.

While the changes in this file look good, it's important to ensure consistency across the entire project.

Please run the following script to verify that these changes are consistent across the codebase:

This script will help identify any inconsistencies in the usage of tenderdash_proto::tonic across the project, excluding the current file.

proto/tests/unit.rs (1)

Line range hint 1-200: Verify test coverage considering recent dependency updates

The existing tests in this file cover various aspects of protobuf functionality, which is good. However, given the recent updates to dependencies like prost, tokio, and tonic mentioned in the PR objectives, it might be beneficial to verify if the current test suite is still comprehensive.

Consider running the following command to check the test coverage:

This will help ensure that the test suite remains robust after the dependency updates.

abci/src/server/codec.rs (4)

204-204: LGTM! Consistent with import changes.

The encode method has been updated to use the newly imported encode_varint function. This change is consistent with the import modifications and maintains the same functionality.


Line range hint 1-290: Overall assessment: Changes look good and align with PR objectives.

The modifications in this file successfully update the usage of prost library components as intended. The changes are consistent across the file, including the test module. The code maintains its original functionality while adapting to the new dependency versions.

A few minor suggestions have been made to further improve error handling and ensure consistency across the codebase. Please consider these suggestions and ensure all tests are passing after the changes.


212-212: LGTM! Ensure all tests are passing.

The test module has been correctly updated to use the new import path for Message. This change maintains consistency with the main code.

To ensure that all tests are passing with the new changes, please run the following command:

#!/bin/bash
# Description: Run all tests for the project

cargo test --all

This will verify that the changes haven't introduced any regressions in the test suite.


12-15: LGTM! Consider verifying import usage across the codebase.

The updated imports align with the PR objective of updating dependencies. The more specific imports from tenderdash_proto::prost improve code clarity and reduce potential naming conflicts.

To ensure consistency across the codebase, please run the following script to verify the usage of these imports:

abci/src/signatures.rs (1)

26-26: Import of CanonicalVote Added

The import of CanonicalVote from tenderdash_proto::types is necessary for its usage in the Signable trait implementation. This update ensures that CanonicalVote is correctly referenced in the code.

#[allow(deprecated)]
#[cfg(feature = "server")]
pub use server::{start_server, CancellationToken, Server, ServerBuilder, ServerRuntime};
pub use tenderdash_proto as proto;
use tenderdash_proto::prost::{DecodeError, EncodeError};
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent Imports Detected

The import of DecodeError and EncodeError in proto/src/error.rs still uses prost::{DecodeError, EncodeError}. To maintain consistency across the codebase, please update this import to tenderdash_proto::prost::{DecodeError, EncodeError}.

🔗 Analysis chain

LGTM! Verify impact on codebase.

The import change from prost to tenderdash_proto::prost for DecodeError and EncodeError looks good and aligns with the PR objectives. This modification likely reflects updates in the dependency structure or aims to maintain consistency across the project.

To ensure this change doesn't introduce any unintended consequences, please run the following script to verify that all usages of DecodeError and EncodeError in the codebase are consistent with this new import:

This script will help identify any inconsistencies in the usage or import of these error types across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of DecodeError and EncodeError from tenderdash_proto::prost

# Test: Search for DecodeError and EncodeError usages
echo "Searching for DecodeError and EncodeError usages:"
rg --type rust -e "DecodeError" -e "EncodeError"

# Test: Verify imports of DecodeError and EncodeError
echo "Verifying imports of DecodeError and EncodeError:"
rg --type rust -e "use .*prost::.*DecodeError" -e "use .*prost::.*EncodeError"

Length of output: 825

proto/tests/unit.rs Outdated Show resolved Hide resolved
@@ -23,8 +23,7 @@ use std::{
};

use bytes::BufMut;
use prost::Message;
use tenderdash_proto::types::CanonicalVote;
use tenderdash_proto::{prost::Message, types::CanonicalVote};

use crate::{
proto::types::{
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the Syntax of the #[deprecated] Attribute

The syntax for the #[deprecated] attribute should include named parameters such as since and note. The correct usage is:

#[deprecated(note = "replaced by calculate_sign_hash() to unify naming between core, platform and tenderdash")]

This ensures that the compiler properly recognizes the deprecation and provides informative warnings.

lklimek and others added 5 commits October 5, 2024 19:32
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

🧹 Outside diff range and nitpick comments (2)
proto/Cargo.toml (2)

Line range hint 2-23: LGTM! Consider adding a version field.

The added package metadata provides comprehensive information about the package, which is excellent for documentation and discoverability. The workspace configurations for rust-version and version are appropriate.

Consider adding a version field to the package metadata, even if it's managed by the workspace. This can help with explicit versioning when the package is used outside the workspace context.


Line range hint 28-46: LGTM! Consider enhancing the deprecation notice.

The features configuration is well-documented, especially the note about protobuf file regeneration. The deprecation of the std feature in favor of grpc is a good practice.

To improve clarity, consider enhancing the deprecation notice for the std feature. You could add a comment explaining why grpc is preferred and when the std feature might be removed in future versions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3d2d494 and 06c59fd.

📒 Files selected for processing (4)
  • abci/Cargo.toml (3 hunks)
  • proto-compiler/Cargo.toml (1 hunks)
  • proto/Cargo.toml (3 hunks)
  • proto/tests/unit.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • abci/Cargo.toml
  • proto-compiler/Cargo.toml
  • proto/tests/unit.rs
🧰 Additional context used
🔇 Additional comments (2)
proto/Cargo.toml (2)

Line range hint 73-79: LGTM! Verify build dependency compatibility.

The update to serde_json in dev-dependencies is consistent with the overall dependency updates.

Please verify that the unchanged build-dependency on tenderdash-proto-compiler is compatible with the updated dependencies. Run the following script to check for any potential issues:

#!/bin/bash
# Description: Verify build dependency compatibility

# Test: Check if tenderdash-proto-compiler builds successfully with updated dependencies
cd ../proto-compiler && cargo check && cd ../proto

# Test: Ensure that the proto compilation still works as expected
cargo clean && cargo build

50-69: LGTM! Verify compatibility with updated dependencies.

The dependency updates align with the PR objectives. The new features added to derive_more (["from", "from_str"]) may introduce new functionality.

Please ensure that the updated dependencies, especially prost and tonic, are compatible with the rest of the codebase. Run the following script to check for any compatibility issues:

@QuantumExplorer QuantumExplorer merged commit 96d0d1b into develop Oct 7, 2024
10 checks passed
@QuantumExplorer QuantumExplorer deleted the build/deps-update branch October 7, 2024 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants