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(abci): add RequestFinalizeSnapshot #119

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Jan 15, 2025

Issue being fixed or feature implemented

For state synchronization, we need a new request, RequestFinalizeSnapshot, that will provide Drive with most recent
block. Drive needs it to verify and rebuild its cached snapshot.

What was done?

  1. Weakened serde_json dependency requirement to fix some build issues,
  2. Implemented new request type, RequestFinalizeSnapshot.
  3. Added test

How Has This Been Tested?

  1. Added unit test.
  2. Tested as part of dash platform state sync effort, feat: abci state sync platform#2413

Breaking Changes

New ABCI endpoint RequestFinalizeSnapshot implemented. Default response can be empty, so non-breaking change, but requires new Tenderdash 1.5.x.

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

Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Walkthrough

This pull request updates dependency versions in the Cargo.toml files for both the abci and proto packages, broadening the version range for the serde_json dependency. It introduces a new finalize_snapshot method in the Application trait, accompanied by a matching arm in the request dispatcher and updates in the tracing span mapping. Additionally, the proto build script now uses a commit hash as the default version.

Changes

Files Change Summary
abci/Cargo.toml, proto/Cargo.toml Updated serde_json dependency versions from specific patch versions (1.0.128, 1.0.125) to a broader "1.0"
abci/src/application.rs Added new method finalize_snapshot to the Application trait and included its match arm in the request handler
abci/src/tracing_span.rs Added new match case for Value::FinalizeSnapshot in the abci_method_name function
proto/build.rs Updated the default version constant from "v1.3.0" to a specific commit hash "a4de86a0008ad817e087cbea99cafd4b51089cdd"

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant RD as RequestDispatcher
    participant A as Application
    C->>RD: Send FinalizeSnapshot request
    RD->>A: Invoke finalize_snapshot(request)
    A-->>RD: Return ResponseFinalizeSnapshot
    RD->>C: Respond with final result
Loading

Suggested reviewers

  • shumkov

Poem

I'm a rabbit with a hop in my step,
Code changes fresh like a springtime prep.
From tweaks on dependencies to snapshot views,
Each line a hop in the coding muse.
Happy ears and whiskers in every new groove!
🐇✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 387968d and 63f5c63.

📒 Files selected for processing (1)
  • abci/src/application.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • abci/src/application.rs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test-all
  • GitHub Check: build (alpine)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@lklimek lklimek marked this pull request as ready for review February 6, 2025 08:30
@lklimek
Copy link
Collaborator Author

lklimek commented Feb 6, 2025

@coderabbitai review all

Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get PR details
gh pr view 119 --json files,additions,deletions,commits

# Get the diff for detailed analysis
gh pr diff 119

# Look for test files
fd -e rs test

Length of output: 6347


🏁 Script executed:

#!/bin/bash
# Look for any existing tests related to snapshots
rg -l "snapshot" --type rust

# Check if there's any documentation for the new method
rg -A 5 "finalize_snapshot" --type rust

# Look for any integration tests
fd integration "tests"

Length of output: 1273


@lklimek Thank you for the PR. I've reviewed the changes and have the following feedback:

  1. Documentation:

    • The new finalize_snapshot method in the Application trait lacks documentation. Please add doc comments explaining:
      • The purpose of this method
      • When it gets called in the ABCI lifecycle
      • What the expected behavior is
      • When the default implementation is appropriate to use
  2. Testing:

    • The new ABCI method appears to lack test coverage. Please add:
      • Unit tests for the default implementation
      • Integration tests demonstrating the method's interaction with the request dispatcher
      • Tests covering error scenarios
  3. Implementation:

    • The default implementation returns an empty response (Default::default()). Please document if this is the expected behavior for applications that don't implement custom snapshot finalization logic.

Would you like me to create an issue to track these improvements?

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
abci/src/application.rs (1)

106-111: Add documentation for the finalize_snapshot method.

The method lacks documentation explaining its purpose and usage, unlike other methods in the trait. Consider adding documentation that explains:

  • When this method is called in the ABCI lifecycle
  • What the method is expected to do
  • Any important considerations for implementations
+    /// Called when all snapshot chunks have been received and applied.
+    /// This allows the application to perform any final cleanup or validation
+    /// of the reconstructed state.
     fn finalize_snapshot(
         &self,
         _request: abci::RequestFinalizeSnapshot,
     ) -> Result<abci::ResponseFinalizeSnapshot, abci::ResponseException> {
         Ok(Default::default())
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fde6de and b34e702.

📒 Files selected for processing (5)
  • abci/Cargo.toml (1 hunks)
  • abci/src/application.rs (2 hunks)
  • abci/src/tracing_span.rs (1 hunks)
  • proto/Cargo.toml (1 hunks)
  • proto/build.rs (1 hunks)
👮 Files not reviewed due to content moderation or server errors (2)
  • abci/src/tracing_span.rs
  • abci/src/application.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-all
🔇 Additional comments (9)
abci/src/tracing_span.rs (3)

90-90: LGTM!

The new match arm for FinalizeSnapshot follows the existing pattern and is correctly placed in alphabetical order.


90-90: LGTM!

The new match arm for FinalizeSnapshot is correctly implemented and maintains the alphabetical ordering of the match arms.


90-90: LGTM!

The addition of the FinalizeSnapshot match arm follows the existing pattern and maintains alphabetical ordering.

abci/src/application.rs (3)

179-179: LGTM!

The new match arm for FinalizeSnapshot is correctly implemented and well-placed with other snapshot-related operations.


179-179: LGTM!

The match arm for FinalizeSnapshot is correctly implemented and follows the established pattern.


179-179: LGTM!

The FinalizeSnapshot match arm is correctly implemented and placed logically with other snapshot-related requests.

proto/build.rs (1)

7-7: Verify the commit hash and consider adding documentation.

Using a commit hash instead of a semantic version makes it harder to track the version being used. Consider:

  1. Adding a comment explaining which version this commit hash represents.
  2. Verifying that this commit hash exists in the Tenderdash repository.
✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Verify the commit hash exists in the Tenderdash repository.

# Test: Check if the commit hash exists in the Tenderdash repository
gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /repos/dashpay/tenderdash/commits/9d3dae43c3803d5372e2b45a087fd1c0f46192fe

Length of output: 4456


Commit hash verified; consider adding inline documentation.

The commit hash 9d3dae43c3803d5372e2b45a087fd1c0f46192fe exists in the Tenderdash repository (commit "chore: fix lint warning" by Lukasz Klimek on 2025-01-20). It’s advisable to add a comment explaining which version this commit represents to aid clarity.

proto/Cargo.toml (1)

83-83: Verify compatibility with the relaxed version constraint.

The version constraint for serde_json has been relaxed from "1.0.125" to "1.0". While this allows for more flexibility, it's important to:

  1. Verify compatibility with other dependencies that might rely on specific serde_json features.
  2. Consider using a minimum version constraint (e.g., "^1.0.125") to ensure compatibility while allowing updates.

Let's check for potential compatibility issues:

abci/Cargo.toml (1)

66-66: Verify compatibility with the relaxed version constraint.

Similar to the change in proto/Cargo.toml, the version constraint for serde_json has been relaxed from "1.0.128" to "1.0". While consistency across packages is good, consider:

  1. Using a minimum version constraint (e.g., "^1.0.128") to ensure compatibility while allowing updates.
  2. Verifying that all features required by the optional serde feature are available in older versions.

Let's check for potential compatibility issues:

abci/src/application.rs Show resolved Hide resolved
lklimek and others added 3 commits February 6, 2025 09:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@lklimek lklimek added this to the 1.3 milestone Feb 6, 2025
@lklimek lklimek requested a review from shumkov February 6, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review / testing
Development

Successfully merging this pull request may close these issues.

2 participants